import "server-only"; import { createClient as createSupabaseClient } from "@supabase/supabase-js"; import type { Database } from "./types"; // Service-role client: bypasses RLS entirely. Server-only — never import this // from a Client Component or anything bundled for the browser. The // "server-only" import makes an accidental client-side import a build error // instead of a runtime one. export function createAdminClient() { const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL; const serviceRoleKey = process.env.SUPABASE_SERVICE_ROLE_KEY; if (!supabaseUrl) { throw new Error("Missing NEXT_PUBLIC_SUPABASE_URL"); } if (!serviceRoleKey) { throw new Error("Missing SUPABASE_SERVICE_ROLE_KEY"); } return createSupabaseClient(supabaseUrl, serviceRoleKey, { auth: { autoRefreshToken: false, persistSession: false }, }); }