fix: handle Docker build placeholder env vars in Supabase clients and VAPID init

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>
This commit is contained in:
Jakob Wennberg
2026-03-03 14:50:46 +01:00
co-authored by Claude Opus 4.6
parent b5b004509d
commit 3909f23725
3 changed files with 26 additions and 6 deletions
+10 -2
View File
@@ -1,8 +1,16 @@
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(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
isBuildPlaceholder ? 'https://placeholder.supabase.co' : url,
isBuildPlaceholder ? 'placeholder' : key
)
}