advance
This commit is contained in:
9
lib/supabase/browser.ts
Normal file → Executable file
9
lib/supabase/browser.ts
Normal file → Executable file
@@ -1,17 +1,16 @@
|
||||
import { createClient, type SupabaseClient } from "@supabase/supabase-js";
|
||||
import { readSupabasePublicConfig } from "@/lib/supabase/config";
|
||||
|
||||
let browserClient: SupabaseClient | null = null;
|
||||
|
||||
export const supabaseBrowser = (): SupabaseClient | null => {
|
||||
const url = process.env.NEXT_PUBLIC_SUPABASE_URL;
|
||||
const anonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
|
||||
|
||||
if (!url || !anonKey) {
|
||||
const config = readSupabasePublicConfig();
|
||||
if (!config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!browserClient) {
|
||||
browserClient = createClient(url, anonKey);
|
||||
browserClient = createClient(config.url, config.anonKey);
|
||||
}
|
||||
|
||||
return browserClient;
|
||||
|
||||
Reference in New Issue
Block a user