mirror of
https://github.com/Sosokker/B2D-Ventures.git
synced 2025-12-19 05:54:06 +01:00
25 lines
704 B
TypeScript
25 lines
704 B
TypeScript
import { createSupabaseClient } from "@/lib/supabase/serverComponentClient";
|
|
import { NextResponse } from "next/server";
|
|
|
|
export async function GET(request: Request) {
|
|
const { searchParams, origin } = new URL(request.url);
|
|
|
|
const code = searchParams.get("code");
|
|
|
|
// if "next" is in param, use it in the redirect URL
|
|
const next = searchParams.get("next") ?? "/";
|
|
|
|
if (code) {
|
|
const supabase = createSupabaseClient();
|
|
|
|
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`);
|
|
}
|