24 lines
842 B
TypeScript
24 lines
842 B
TypeScript
import { NextResponse } from "next/server"
|
|
import { createClient } from "@/lib/supabase/server"
|
|
|
|
export async function GET(request: Request) {
|
|
const { searchParams, origin } = new URL(request.url)
|
|
const code = searchParams.get("code")
|
|
const type = searchParams.get("type")
|
|
const next = searchParams.get("next") ?? "/feed"
|
|
|
|
// If this is a password recovery flow, handle it specifically
|
|
if (type === 'recovery') {
|
|
return NextResponse.redirect(`${process.env.NEXT_PUBLIC_SITE_URL}/auth/update-password`)
|
|
}
|
|
|
|
if (code) {
|
|
const supabase = await createClient()
|
|
const { error } = await supabase.auth.exchangeCodeForSession(code)
|
|
if (!error) {
|
|
return NextResponse.redirect(`${process.env.NEXT_PUBLIC_SITE_URL}${next}`)
|
|
}
|
|
}
|
|
|
|
return NextResponse.redirect(`${process.env.NEXT_PUBLIC_SITE_URL}/auth/error`)
|
|
} |