Skip to content

Commit 916bc1a

Browse files
committed
Fix: Explicitly set Supabase session cookies on OAuth callback response for Next.js app router
1 parent 461667d commit 916bc1a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

app/auth/callback/route.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ export async function GET(request: NextRequest) {
2929
if (error) {
3030
return NextResponse.redirect(new URL('/login?error=oauth', request.url))
3131
}
32+
33+
// Collect all cookies and set them on the response
34+
const allCookies = cookieStore.getAll();
35+
const response = NextResponse.redirect(new URL('/', request.url));
36+
for (const cookie of allCookies) {
37+
response.cookies.set(cookie.name, cookie.value, cookie);
38+
}
39+
return response;
3240
}
3341

3442
// Always redirect to the main app after successful authentication

0 commit comments

Comments
 (0)