eny.space Landingpage
1import { createClient } from "@supabase/supabase-js";
2
3// Admin client for server-side operations that bypass RLS
4// Use this ONLY in server-side code that needs to bypass RLS (like webhooks)
5export function createAdminClient() {
6 const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
7 const supabaseServiceKey = process.env.SUPABASE_SERVICE_ROLE_KEY;
8
9 if (!supabaseUrl || !supabaseServiceKey) {
10 throw new Error(
11 "Missing Supabase admin credentials. Please set NEXT_PUBLIC_SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY in your environment variables."
12 );
13 }
14
15 return createClient(supabaseUrl, supabaseServiceKey, {
16 auth: {
17 autoRefreshToken: false,
18 persistSession: false,
19 },
20 });
21}