Files
cloudrite/app/auth/callback/route.ts
T
v0andASOwnerYT 1386f6e549 feat: implement Supabase authentication with Google OAuth
Add Supabase client, middleware, and auth pages; update header for auth state.

Co-authored-by: ASOwnerYT <[email protected]>
2026-03-22 23:07:11 +00:00

20 lines
620 B
TypeScript

import { createClient } from '@/lib/supabase/server'
import { NextResponse } from 'next/server'
export async function GET(request: Request) {
const { searchParams, origin } = new URL(request.url)
const code = searchParams.get('code')
const next = searchParams.get('next') ?? '/dashboard'
if (code) {
const supabase = await createClient()
const { error } = await supabase.auth.exchangeCodeForSession(code)
if (!error) {
return NextResponse.redirect(`${origin}${next}`)
}
}
// Return the user to an error page with instructions
return NextResponse.redirect(`${origin}/auth/error`)
}