Supabase proper redirect

This commit is contained in:
2026-02-05 17:27:14 +01:00
parent e0f023f1fb
commit bc65ca57c2
5 changed files with 66 additions and 3 deletions
+22
View File
@@ -0,0 +1,22 @@
// app/auth/callback/route.ts
import { NextRequest, NextResponse } from "next/server";
import { createClient } from "@/lib/supabase/server";
export async function GET(req: NextRequest) {
const code = req.nextUrl.searchParams.get("code");
if (!code) {
return NextResponse.json({ error: "code param required" }, { status: 400 });
}
const supabase = await createClient();
const { error } = await supabase.auth.exchangeCodeForSession(code);
if (error) {
console.error(error);
return NextResponse.json({ error: error.message }, { status: 500 });
}
return NextResponse.redirect(new URL("/runs", req.url));
}