modified: lib/supabase/client.ts
This commit is contained in:
parent
3dcd638f99
commit
334dc8d34a
1 changed files with 14 additions and 4 deletions
|
|
@ -1,8 +1,18 @@
|
||||||
import { createBrowserClient } from '@supabase/ssr'
|
import { createBrowserClient } from '@supabase/ssr'
|
||||||
|
|
||||||
export function createClient() {
|
export function createClient() {
|
||||||
return createBrowserClient(
|
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL
|
||||||
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY
|
||||||
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
|
|
||||||
)
|
// During build/prerendering, env vars may not be available
|
||||||
|
// Return a placeholder that will be replaced at runtime
|
||||||
|
if (!supabaseUrl || !supabaseAnonKey) {
|
||||||
|
if (typeof window === 'undefined') {
|
||||||
|
// Server-side during build - return a mock that won't be used
|
||||||
|
return null as any
|
||||||
|
}
|
||||||
|
throw new Error('Missing Supabase environment variables')
|
||||||
|
}
|
||||||
|
|
||||||
|
return createBrowserClient(supabaseUrl, supabaseAnonKey)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue