3909f23725
Docker builds use __NEXT_PUBLIC_*__ sentinel values that get replaced at runtime by docker-entrypoint.sh. These placeholders caused build failures: - Supabase client constructor rejected invalid URL during page prerendering - web-push VAPID init rejected invalid key format Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
17 lines
655 B
TypeScript
17 lines
655 B
TypeScript
import { createBrowserClient } from '@supabase/ssr'
|
|
|
|
// During Docker builds, NEXT_PUBLIC_* vars are placeholder sentinels
|
|
// (e.g. __NEXT_PUBLIC_SUPABASE_URL__) that get replaced at runtime by
|
|
// docker-entrypoint.sh. Provide a dummy URL so the client constructor
|
|
// doesn't throw during Next.js static page generation.
|
|
const url = process.env.NEXT_PUBLIC_SUPABASE_URL!
|
|
const key = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
|
|
const isBuildPlaceholder = url.startsWith('__')
|
|
|
|
export function createClient() {
|
|
return createBrowserClient(
|
|
isBuildPlaceholder ? 'https://placeholder.supabase.co' : url,
|
|
isBuildPlaceholder ? 'placeholder' : key
|
|
)
|
|
}
|