| import { createServerClient } from "@supabase/ssr"; | |
| import { cookies } from "next/headers"; | |
| export async function getSupabaseServer() { | |
| const cookieStore = await cookies(); | |
| return createServerClient( | |
| process.env.NEXT_PUBLIC_SUPABASE_URL!, | |
| process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!, | |
| { | |
| cookies: { | |
| getAll() { | |
| return cookieStore.getAll(); | |
| }, | |
| setAll(tokens) { | |
| try { | |
| for (const { name, value, options } of tokens) { | |
| cookieStore.set(name, value, options); | |
| } | |
| } catch { | |
| // Server component – cookies are read-only | |
| } | |
| }, | |
| }, | |
| } | |
| ); | |
| } | |