added error handling

This commit is contained in:
Nate Kelley 2025-04-18 09:14:49 -06:00
parent 70b3421d34
commit a1fa893bff
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
2 changed files with 8 additions and 0 deletions

View File

@ -7,6 +7,7 @@ export async function GET(request: Request) {
const code = searchParams.get('code_challenge') || searchParams.get('code'); //we were not seeing code, just code_challenge? const code = searchParams.get('code_challenge') || searchParams.get('code'); //we were not seeing code, just code_challenge?
// if "next" is in param, use it as the redirect URL // if "next" is in param, use it as the redirect URL
const next = searchParams.get('next') ?? '/'; const next = searchParams.get('next') ?? '/';
if (code) { if (code) {
const supabase = await createClient(); const supabase = await createClient();
const { error } = await supabase.auth.exchangeCodeForSession(code); const { error } = await supabase.auth.exchangeCodeForSession(code);
@ -23,6 +24,8 @@ export async function GET(request: Request) {
return NextResponse.redirect(`${origin}/app`); return NextResponse.redirect(`${origin}/app`);
} }
} }
console.error('ERROR EXCHANGING CODE FOR SESSION', { error });
} }
// return the user to an error page with instructions // return the user to an error page with instructions

View File

@ -20,9 +20,14 @@ export async function GET(request: NextRequest) {
if (!error) { if (!error) {
// redirect user to specified redirect URL or root of app // redirect user to specified redirect URL or root of app
redirect(next); redirect(next);
return;
} }
console.error(error);
} }
console.error('NO TOKEN HASH OR TYPE', { token_hash, type });
// redirect the user to an error page with some instructions // redirect the user to an error page with some instructions
redirect('/auth/auth-code-error'); redirect('/auth/auth-code-error');
} }