|
@@ -1,13 +1,33 @@
|
|
|
-import { NextResponse } from "next/server";
|
|
|
|
|
-import { getSupabaseServerClient } from "@/lib/supabase/server";
|
|
|
|
|
|
|
+import { createServerClient, type CookieOptions } from "@supabase/ssr";
|
|
|
|
|
+import { NextRequest, NextResponse } from "next/server";
|
|
|
|
|
+import { getSupabaseCookieName } from "@/lib/supabase/cookie-name";
|
|
|
|
|
|
|
|
-export async function POST() {
|
|
|
|
|
- const supabase = await getSupabaseServerClient();
|
|
|
|
|
- const { error } = await supabase.auth.signOut();
|
|
|
|
|
|
|
+export async function POST(request: NextRequest) {
|
|
|
|
|
+ const response = NextResponse.json({ ok: true });
|
|
|
|
|
+
|
|
|
|
|
+ const supabaseUrl = process.env.SUPABASE_INTERNAL_URL || process.env.NEXT_PUBLIC_SUPABASE_URL;
|
|
|
|
|
+ const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
|
|
|
|
|
+ if (!supabaseUrl || !supabaseAnonKey) {
|
|
|
|
|
+ return NextResponse.json({ error: "Supabase not configured" }, { status: 500 });
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ const supabase = createServerClient(supabaseUrl, supabaseAnonKey, {
|
|
|
|
|
+ cookieOptions: { name: getSupabaseCookieName() },
|
|
|
|
|
+ cookies: {
|
|
|
|
|
+ getAll() {
|
|
|
|
|
+ return request.cookies.getAll();
|
|
|
|
|
+ },
|
|
|
|
|
+ setAll(cookiesToSet: Array<{ name: string; value: string; options: CookieOptions }>) {
|
|
|
|
|
+ cookiesToSet.forEach(({ name, value, options }) =>
|
|
|
|
|
+ response.cookies.set(name, value, options),
|
|
|
|
|
+ );
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ const { error } = await supabase.auth.signOut();
|
|
|
if (error) {
|
|
if (error) {
|
|
|
return NextResponse.json({ error: "Failed to sign out" }, { status: 500 });
|
|
return NextResponse.json({ error: "Failed to sign out" }, { status: 500 });
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- return NextResponse.json({ ok: true });
|
|
|
|
|
|
|
+ return response;
|
|
|
}
|
|
}
|