modified: lib/supabase/client.ts

This commit is contained in:
Anderson 2026-02-12 22:37:00 +00:00 committed by GitHub
parent 3dcd638f99
commit 334dc8d34a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)
} }