mirror of
https://github.com/D4M13N-D3V/neroshitron.git
synced 2025-03-14 10:05:04 +00:00
20 lines
725 B
TypeScript
20 lines
725 B
TypeScript
|
import { createClient } from "@/utils/supabase/server";
|
||
|
import { NextResponse } from "next/server";
|
||
|
|
||
|
export async function GET(request: Request) {
|
||
|
// The `/auth/callback` route is required for the server-side auth flow implemented
|
||
|
// by the SSR package. It exchanges an auth code for the user's session.
|
||
|
// https://supabase.com/docs/guides/auth/server-side/nextjs
|
||
|
const requestUrl = new URL(request.url);
|
||
|
const code = requestUrl.searchParams.get("code");
|
||
|
const origin = requestUrl.origin;
|
||
|
|
||
|
if (code) {
|
||
|
const supabase = createClient();
|
||
|
await supabase.auth.exchangeCodeForSession(code);
|
||
|
}
|
||
|
|
||
|
// URL to redirect to after sign up process completes
|
||
|
return NextResponse.redirect(`${origin}/protected`);
|
||
|
}
|