mirror of
https://github.com/SkalaraAI/skalara.git
synced 2025-04-09 15:10:16 -04:00
22 lines
844 B
TypeScript
22 lines
844 B
TypeScript
import { createRouteHandlerClient } from '@supabase/auth-helpers-nextjs'
|
|
import { cookies } from 'next/headers'
|
|
import { NextResponse } from 'next/server'
|
|
|
|
export const dynamic = 'force-dynamic'
|
|
|
|
export async function GET(request: Request) {
|
|
// The `/auth/callback` route is required for the server-side auth flow implemented
|
|
// by the Auth Helpers package. It exchanges an auth code for the user's session.
|
|
// https://supabase.com/docs/guides/auth/auth-helpers/nextjs#managing-sign-in-with-code-exchange
|
|
const requestUrl = new URL(request.url)
|
|
const code = requestUrl.searchParams.get('code')
|
|
|
|
if (code) {
|
|
const supabase = createRouteHandlerClient({ cookies })
|
|
await supabase.auth.exchangeCodeForSession(code)
|
|
}
|
|
|
|
// URL to redirect to after sign in process completes
|
|
return NextResponse.redirect(requestUrl.origin)
|
|
}
|