Make server Supabase admin client lazy to avoid throwing when env vars are missing

cgen-2511e57fc8184810b367c98c9a2cf91e
This commit is contained in:
Builder.io 2025-09-30 00:13:34 +00:00
parent c3ac16c346
commit 1df7a691db

View file

@ -13,6 +13,11 @@ if (!SUPABASE_SERVICE_ROLE) {
);
}
export const adminSupabase = createClient(SUPABASE_URL, SUPABASE_SERVICE_ROLE, {
auth: { autoRefreshToken: false, persistSession: false },
});
let admin: any = null;
if (SUPABASE_URL && SUPABASE_SERVICE_ROLE) {
admin = createClient(SUPABASE_URL, SUPABASE_SERVICE_ROLE, {
auth: { autoRefreshToken: false, persistSession: false },
});
}
export const adminSupabase = admin as ReturnType<typeof createClient>;