2026-03-20 21:41:38 +01:00
|
|
|
import { createClient, type SupabaseClient } from '@supabase/supabase-js'
|
|
|
|
|
|
|
|
|
|
const supabaseUrl = import.meta.env['VITE_SUPABASE_URL'] ?? ''
|
|
|
|
|
const supabaseAnonKey = import.meta.env['VITE_SUPABASE_ANON_KEY'] ?? ''
|
|
|
|
|
|
|
|
|
|
function createSupabaseClient(): SupabaseClient {
|
|
|
|
|
if (!supabaseUrl || !supabaseAnonKey) {
|
|
|
|
|
// Return a stub client for tests/dev without Supabase configured
|
2026-03-20 22:11:39 +01:00
|
|
|
// Uses port 9999 to match local GoTrue container
|
|
|
|
|
return createClient('http://localhost:9999', 'stub-key')
|
2026-03-20 21:41:38 +01:00
|
|
|
}
|
|
|
|
|
return createClient(supabaseUrl, supabaseAnonKey)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const supabase = createSupabaseClient()
|