diff --git a/lib/supabase/client.ts b/lib/supabase/client.ts index 792b457..28d53cc 100644 --- a/lib/supabase/client.ts +++ b/lib/supabase/client.ts @@ -1,8 +1,18 @@ import { createBrowserClient } from '@supabase/ssr' export function createClient() { - return createBrowserClient( - process.env.NEXT_PUBLIC_SUPABASE_URL!, - process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY! - ) + const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL + const supabaseAnonKey = 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) }