Samad14's picture
Re-enable OAuth: restore auth pages, Providers wrapper, dashboard auth guard, landing page CTA
dc1f75e
Raw History Blame Contribute Delete
579 Bytes
import { createClient } from '@supabase/supabase-js';
let _client: ReturnType<typeof createClient> | null = null;
export function getSupabase() {
if (!_client) {
const url = process.env.NEXT_PUBLIC_SUPABASE_URL;
const key = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
if (!url || !key) {
throw new Error('Missing NEXT_PUBLIC_SUPABASE_URL or NEXT_PUBLIC_SUPABASE_ANON_KEY');
}
_client = createClient(url, key, {
auth: { flowType: 'pkce', persistSession: true, autoRefreshToken: true, detectSessionInUrl: false },
});
}
return _client;
}