16 lines
684 B
TypeScript
16 lines
684 B
TypeScript
import 'server-only'
|
|
import { createClient as createSupabaseClient, type SupabaseClient } from '@supabase/supabase-js'
|
|
|
|
// Service-role client — bypasses RLS. Server-side only, and only for operations
|
|
// the anon client cannot perform (auth admin user invites). Never import in client code.
|
|
export function createAdminClient(): SupabaseClient {
|
|
const url = process.env.NEXT_PUBLIC_SUPABASE_URL
|
|
const serviceRoleKey = process.env.SUPABASE_SERVICE_ROLE_KEY
|
|
if (!url || !serviceRoleKey) {
|
|
throw new Error('SUPABASE_SERVICE_ROLE_KEY not configured')
|
|
}
|
|
return createSupabaseClient(url, serviceRoleKey, {
|
|
auth: { autoRefreshToken: false, persistSession: false },
|
|
})
|
|
}
|