87a2f93edb
Introduce user registration/login gated behind optional NEXT_PUBLIC_SUPABASE_* env vars (leave blank to disable — app behaves exactly as before). Adds proxy.ts for automatic cookie session refresh, requireUser() API route guards on all 7 compute-consuming routes, AuthModal (Google/GitHub OAuth + 6-digit email OTP), UserChip header component, and login_success analytics event. Identity is fully decoupled from Session/engine — no type changes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
21 lines
563 B
TypeScript
21 lines
563 B
TypeScript
import { createServerClient } from "@supabase/ssr";
|
|
import { cookies } from "next/headers";
|
|
|
|
export async function createClient() {
|
|
const cookieStore = await cookies();
|
|
return createServerClient(
|
|
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
|
process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY!,
|
|
{
|
|
cookies: {
|
|
getAll: () => cookieStore.getAll(),
|
|
setAll: (cookiesToSet) => {
|
|
for (const { name, value, options } of cookiesToSet) {
|
|
cookieStore.set(name, value, options);
|
|
}
|
|
},
|
|
},
|
|
},
|
|
);
|
|
}
|