diff --git a/extensions/general/push-notifications/notification-sender.ts b/extensions/general/push-notifications/notification-sender.ts index 9350467e..e7f338f9 100644 --- a/extensions/general/push-notifications/notification-sender.ts +++ b/extensions/general/push-notifications/notification-sender.ts @@ -18,7 +18,11 @@ const vapidPublicKey = process.env.NEXT_PUBLIC_VAPID_PUBLIC_KEY const vapidPrivateKey = process.env.VAPID_PRIVATE_KEY const vapidSubject = process.env.VAPID_SUBJECT || 'mailto:support@erp-base.se' -if (vapidPublicKey && vapidPrivateKey) { +if ( + vapidPublicKey && + vapidPrivateKey && + !vapidPublicKey.startsWith('__') +) { webpush.setVapidDetails(vapidSubject, vapidPublicKey, vapidPrivateKey) } diff --git a/lib/supabase/client.ts b/lib/supabase/client.ts index 792b4570..80bfbf49 100644 --- a/lib/supabase/client.ts +++ b/lib/supabase/client.ts @@ -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 ) } diff --git a/lib/supabase/server.ts b/lib/supabase/server.ts index dd04eb65..0ff8db00 100644 --- a/lib/supabase/server.ts +++ b/lib/supabase/server.ts @@ -1,12 +1,20 @@ import { createServerClient } from '@supabase/ssr' import { cookies } from 'next/headers' +// During Docker builds, NEXT_PUBLIC_* vars are placeholder sentinels +// replaced at runtime by docker-entrypoint.sh. +const url = process.env.NEXT_PUBLIC_SUPABASE_URL! +const key = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY! +const isBuildPlaceholder = url?.startsWith('__') +const safeUrl = isBuildPlaceholder ? 'https://placeholder.supabase.co' : url +const safeKey = isBuildPlaceholder ? 'placeholder' : key + export async function createClient() { const cookieStore = await cookies() return createServerClient( - process.env.NEXT_PUBLIC_SUPABASE_URL!, - process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!, + safeUrl, + safeKey, { cookies: { getAll() { @@ -32,7 +40,7 @@ export async function createServiceClient() { const cookieStore = await cookies() return createServerClient( - process.env.NEXT_PUBLIC_SUPABASE_URL!, + safeUrl, process.env.SUPABASE_SERVICE_ROLE_KEY!, { cookies: {