From 60ef5ddab9b54d78abd1811e7322301a4827c7bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Tonh=C3=A4user?= Date: Tue, 11 Aug 2026 16:17:34 +0200 Subject: [PATCH] fix: use runtime legal page URLs --- Dockerfile | 4 ---- compose.yaml | 8 ++++---- docs/operations.md | 6 +++--- src/app/layout.tsx | 4 ++++ src/config/env.test.ts | 23 +++++++++++++++++++++++ src/config/env.ts | 10 +++++++--- 6 files changed, 41 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9db7c58..175189d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,10 +27,6 @@ ENV SMTP_PORT=587 ENV SMTP_USER=portal@localhost ENV SMTP_PASSWORD=dummy-password ENV SMTP_FROM=portal@localhost -ENV LEGAL_IMPRINT_URL=https://example.com/impressum -ENV LEGAL_PRIVACY_URL=https://example.com/datenschutz -ENV LEGAL_TERMS_URL=https://example.com/nutzungsbedingungen - RUN pnpm build FROM node:24-alpine AS runner diff --git a/compose.yaml b/compose.yaml index d302970..3909d04 100644 --- a/compose.yaml +++ b/compose.yaml @@ -12,9 +12,9 @@ x-portal-env: &portal-env SMTP_USER: ${SMTP_USER} SMTP_PASSWORD: ${SMTP_PASSWORD} SMTP_FROM: ${SMTP_FROM} - LEGAL_IMPRINT_URL: ${LEGAL_IMPRINT_URL} - LEGAL_PRIVACY_URL: ${LEGAL_PRIVACY_URL} - LEGAL_TERMS_URL: ${LEGAL_TERMS_URL} + LEGAL_IMPRINT_URL: ${LEGAL_IMPRINT_URL:-https://leon-tonhaeuser.de/impressum} + LEGAL_PRIVACY_URL: ${LEGAL_PRIVACY_URL:-https://leon-tonhaeuser.de/datenschutz} + LEGAL_TERMS_URL: ${LEGAL_TERMS_URL:-https://leon-tonhaeuser.de/agb} services: portal-db: @@ -109,4 +109,4 @@ networks: portal-internal: internal: true immich_default: - external: true \ No newline at end of file + external: true diff --git a/docs/operations.md b/docs/operations.md index c66f4cb..8248eda 100644 --- a/docs/operations.md +++ b/docs/operations.md @@ -31,9 +31,9 @@ All production configuration is provided via environment variables (e.g. `.env` | `SMTP_USER` | SMTP username | `portal@example.de` | | `SMTP_PASSWORD` | SMTP password | Confidential | | `SMTP_FROM` | Default From email address | `Leon Tonhäuser Presse ` | -| `LEGAL_IMPRINT_URL` | Public Impressum link | `https://example.de/impressum` | -| `LEGAL_PRIVACY_URL` | Public Datenschutz link | `https://example.de/datenschutz` | -| `LEGAL_TERMS_URL` | Public Nutzungsbedingungen link | `https://example.de/terms` | +| `LEGAL_IMPRINT_URL` | Public Impressum link | `https://leon-tonhaeuser.de/impressum` | +| `LEGAL_PRIVACY_URL` | Public Datenschutz link | `https://leon-tonhaeuser.de/datenschutz` | +| `LEGAL_TERMS_URL` | Public Nutzungsbedingungen link | `https://leon-tonhaeuser.de/agb` | --- diff --git a/src/app/layout.tsx b/src/app/layout.tsx index dd15f9e..5f1d4ae 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -14,6 +14,10 @@ export const metadata: Metadata = { description: "Ausgewählte Pressefotos sicher finden und nutzen.", }; +// Legal destinations are runtime configuration. Keep the shared layout +// dynamic so Docker build-time placeholders can never be baked into pages. +export const dynamic = "force-dynamic"; + export default function RootLayout({ children }: Readonly<{ children: ReactNode }>) { return ( diff --git a/src/config/env.test.ts b/src/config/env.test.ts index 5d919e6..04a5736 100644 --- a/src/config/env.test.ts +++ b/src/config/env.test.ts @@ -7,4 +7,27 @@ describe("parseServerEnv", () => { /IMMICH_API_KEY/, ); }); + + test("uses the production legal pages when no overrides are configured", () => { + const parsed = parseServerEnv({ + DATABASE_URL: "postgres://portal:secret@portal-db:5432/portal", + BETTER_AUTH_SECRET: "test-secret-at-least-thirty-two-characters", + BETTER_AUTH_URL: "https://redaktionen.leon-tonhaeuser.de", + IMMICH_BASE_URL: "http://immich-server:2283", + IMMICH_API_KEY: "test-immich-key", + SMTP_HOST: "smtp.example.com", + SMTP_PORT: "587", + SMTP_USER: "portal@example.com", + SMTP_PASSWORD: "test-smtp-password", + SMTP_FROM: "portal@example.com", + }); + + expect(parsed.LEGAL_IMPRINT_URL).toBe( + "https://leon-tonhaeuser.de/impressum", + ); + expect(parsed.LEGAL_PRIVACY_URL).toBe( + "https://leon-tonhaeuser.de/datenschutz", + ); + expect(parsed.LEGAL_TERMS_URL).toBe("https://leon-tonhaeuser.de/agb"); + }); }); diff --git a/src/config/env.ts b/src/config/env.ts index b38502e..45d2676 100644 --- a/src/config/env.ts +++ b/src/config/env.ts @@ -13,9 +13,13 @@ const serverEnvSchema = z.object({ SMTP_USER: z.string().min(1), SMTP_PASSWORD: z.string().min(1), SMTP_FROM: z.string().min(1), - LEGAL_IMPRINT_URL: z.url(), - LEGAL_PRIVACY_URL: z.url(), - LEGAL_TERMS_URL: z.url(), + LEGAL_IMPRINT_URL: z + .url() + .default("https://leon-tonhaeuser.de/impressum"), + LEGAL_PRIVACY_URL: z + .url() + .default("https://leon-tonhaeuser.de/datenschutz"), + LEGAL_TERMS_URL: z.url().default("https://leon-tonhaeuser.de/agb"), }); export type ServerEnv = z.infer;