Skip to content

Commit a8384b6

Browse files
fix(auth): use createRouteHandlerClient in callback for proper session cookies
The callback route was using createClient() which silently ignores cookie set operations (designed for Server Components). This caused session cookies to not be set after OAuth callback, resulting in users being unable to login despite successful GitHub authentication. Changed to createRouteHandlerClient() which properly handles cookie operations in Route Handlers, allowing session cookies to be set correctly after exchangeCodeForSession(). Root cause: createClient() wraps cookie.set() in try-catch and ignores failures, while createRouteHandlerClient() propagates errors properly.
1 parent c62eece commit a8384b6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

app/auth/callback/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { cookies } from 'next/headers'
1313
import { NextResponse } from 'next/server'
1414

1515
import { createFirstBoardIfNeeded } from '@/lib/actions/board'
16-
import { createClient } from '@/lib/supabase/server'
16+
import { createRouteHandlerClient } from '@/lib/supabase/server'
1717

1818
// Cookie name
1919
const GITHUB_TOKEN_COOKIE = 'github_provider_token'
@@ -41,7 +41,7 @@ export async function GET(request: Request) {
4141
const next = searchParams.get('next') ?? '/boards'
4242

4343
if (code) {
44-
const supabase = await createClient()
44+
const supabase = await createRouteHandlerClient(request)
4545

4646
try {
4747
// Establish session using authentication code

0 commit comments

Comments
 (0)