diff --git a/src/lib/auth/oauth.ts b/src/lib/auth/oauth.ts index 9f1a442..dfe3181 100644 --- a/src/lib/auth/oauth.ts +++ b/src/lib/auth/oauth.ts @@ -33,7 +33,7 @@ export const vkOAuthConfig = { clientId: process.env.VK_CLIENT_ID || '', clientSecret: process.env.VK_CLIENT_SECRET || '', authUrl: 'https://id.vk.com/oauth2/auth', - tokenUrl: 'https://id.vk.ru/oauth2/auth', + tokenUrl: 'https://id.vk.com/oauth2/auth', scope: 'email phone', }; diff --git a/src/pages/api/auth/callback/vk.ts b/src/pages/api/auth/callback/vk.ts index e6abc39..62cbe50 100644 --- a/src/pages/api/auth/callback/vk.ts +++ b/src/pages/api/auth/callback/vk.ts @@ -20,6 +20,7 @@ export const GET: APIRoute = async ({ url, request }) => { const storedState = getCookieValue(cookieHeader, 'oauth_state'); if (!code || !state || !verifier || state !== storedState) { + console.error('[OAuth VK] Validation failed:', { hasCode: !!code, hasState: !!state, hasVerifier: !!verifier, stateMatch: state === storedState }); return new Response(JSON.stringify({ error: 'Invalid or missing parameters' }), { status: 400, headers: { 'Content-Type': 'application/json' }, @@ -42,7 +43,9 @@ export const GET: APIRoute = async ({ url, request }) => { }); if (!tokenRes.ok) { - return new Response(JSON.stringify({ error: 'Token exchange failed' }), { + const errorText = await tokenRes.text(); + console.error('[OAuth VK] Token exchange failed:', tokenRes.status, errorText); + return new Response(JSON.stringify({ error: 'Token exchange failed', details: errorText }), { status: 500, headers: { 'Content-Type': 'application/json' }, }); diff --git a/src/pages/api/auth/callback/yandex.ts b/src/pages/api/auth/callback/yandex.ts index 1174c63..8a40ca9 100644 --- a/src/pages/api/auth/callback/yandex.ts +++ b/src/pages/api/auth/callback/yandex.ts @@ -20,6 +20,7 @@ export const GET: APIRoute = async ({ url, request }) => { const storedState = getCookieValue(cookieHeader, 'oauth_state'); if (!code || !state || !verifier || state !== storedState) { + console.error('[OAuth Yandex] Validation failed:', { hasCode: !!code, hasState: !!state, hasVerifier: !!verifier, stateMatch: state === storedState }); return new Response(JSON.stringify({ error: 'Invalid or missing parameters' }), { status: 400, headers: { 'Content-Type': 'application/json' }, @@ -43,7 +44,9 @@ export const GET: APIRoute = async ({ url, request }) => { }); if (!tokenRes.ok) { - return new Response(JSON.stringify({ error: 'Token exchange failed' }), { + const errorText = await tokenRes.text(); + console.error('[OAuth Yandex] Token exchange failed:', tokenRes.status, errorText); + return new Response(JSON.stringify({ error: 'Token exchange failed', details: errorText }), { status: 500, headers: { 'Content-Type': 'application/json' }, });