fix(oauth): fix VK token URL (.ru -> .com), add error logging to callbacks

This commit is contained in:
emil
2026-05-15 01:50:45 +03:00
parent da0ee46bc0
commit da6208de50
3 changed files with 9 additions and 3 deletions
+1 -1
View File
@@ -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',
};
+4 -1
View File
@@ -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' },
});
+4 -1
View File
@@ -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' },
});