import "server-only"; import { createServerClient } from "@supabase/ssr"; import { cookies } from "next/headers"; import { serverEnvironment } from "@/config/server"; export async function createAdminAuthClient() { const url = serverEnvironment.SALIX_SUPABASE_URL; const publishableKey = serverEnvironment.SALIX_SUPABASE_PUBLISHABLE_KEY; if (url === undefined || publishableKey === undefined) return null; const cookieStore = await cookies(); return createServerClient(url, publishableKey, { cookies: { getAll: () => cookieStore.getAll(), setAll: (values) => { try { for (const { name, options, value } of values) cookieStore.set(name, value, options); } catch { // Server Components cannot write cookies; proxy.ts owns refresh writes. } }, }, }); }