From 321507b570284e8629701a69a8f1cffd4aa7ea44 Mon Sep 17 00:00:00 2001 From: Arnaud Date: Sun, 12 Jul 2026 12:16:11 +0200 Subject: [PATCH] fix: docker build crash when STORAGE_PUBLIC_URL unset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit compose.prod.yml passes STORAGE_PUBLIC_URL through ${STORAGE_PUBLIC_URL} build args/env — when unset in .env.production, docker-compose substitutes an empty string, not an absent var. ?? only falls back on null/undefined, so next.config.ts's `new URL("")` threw and failed the whole `pnpm --filter web build` step. Switched to || in next.config.ts and lib/storage.ts so empty string also falls back to the default. Co-Authored-By: Claude Sonnet 5 --- apps/web/lib/storage.ts | 6 +++--- apps/web/next.config.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/web/lib/storage.ts b/apps/web/lib/storage.ts index 68c3358..b50a828 100644 --- a/apps/web/lib/storage.ts +++ b/apps/web/lib/storage.ts @@ -1,9 +1,9 @@ import { S3Client, PutObjectCommand, DeleteObjectCommand } from "@aws-sdk/client-s3"; import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -const bucket = process.env["STORAGE_BUCKET"] ?? "epicure-uploads"; -const endpoint = process.env["STORAGE_ENDPOINT"] ?? "http://localhost:9000"; -const publicUrl = process.env["STORAGE_PUBLIC_URL"] ?? "http://localhost:9000"; +const bucket = process.env["STORAGE_BUCKET"] || "epicure-uploads"; +const endpoint = process.env["STORAGE_ENDPOINT"] || "http://localhost:9000"; +const publicUrl = process.env["STORAGE_PUBLIC_URL"] || "http://localhost:9000"; const credentials = { accessKeyId: process.env["STORAGE_ACCESS_KEY"] ?? "minioadmin", diff --git a/apps/web/next.config.ts b/apps/web/next.config.ts index da55001..1190a9f 100644 --- a/apps/web/next.config.ts +++ b/apps/web/next.config.ts @@ -1,6 +1,6 @@ import type { NextConfig } from "next"; -const storagePublicUrl = process.env["STORAGE_PUBLIC_URL"] ?? "http://localhost:9000"; +const storagePublicUrl = process.env["STORAGE_PUBLIC_URL"] || "http://localhost:9000"; const storageUrl = new URL(storagePublicUrl); const storageOrigin = storageUrl.origin;