Skip to content

Commit 19a9821

Browse files
waleedlatif1claude
andcommitted
fix(docker): restore NEXT_PUBLIC_APP_URL build arg with dummy fallback
getBaseUrl() in lib/core/utils/urls is evaluated at module load during next build's page-data collection and throws if NEXT_PUBLIC_APP_URL is unset. PR #4658 removed the build arg, breaking the Docker build at the "/_not-found" page-data collection step. Restore the dummy localhost fallback (mirroring DATABASE_URL). The CORS fix from #4658 is preserved: next.config.ts no longer reads NEXT_PUBLIC_APP_URL at build time, and no module-level expression captures getBaseUrl() — every caller invokes it at request time, where getEnv() reads the deployed container env. The dummy localhost value cannot leak into runtime CORS response headers. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 6414b93 commit 19a9821

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

docker/app.Dockerfile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,19 @@ ENV NEXT_TELEMETRY_DISABLED=1 \
6969
VERCEL_TELEMETRY_DISABLED=1 \
7070
DOCKER_BUILD=1
7171

72-
# Provide dummy database URLs during image build so server code that imports @sim/db
73-
# can be evaluated without crashing. Runtime environments should override these.
72+
# Provide dummy values during image build so module-eval-time validators
73+
# (e.g. @sim/db connection init, getBaseUrl() in lib/core/utils/urls) don't
74+
# crash next build during page-data collection. Runtime environments must
75+
# override both. NEXT_PUBLIC_APP_URL is intentionally NOT read by
76+
# next.config.ts at build time — response CORS is computed at request time
77+
# in proxy.ts via getEnv(), so the localhost fallback below cannot leak
78+
# into production CORS response headers.
7479
ARG DATABASE_URL="postgresql://user:pass@localhost:5432/dummy"
7580
ENV DATABASE_URL=${DATABASE_URL}
7681

82+
ARG NEXT_PUBLIC_APP_URL="http://localhost:3000"
83+
ENV NEXT_PUBLIC_APP_URL=${NEXT_PUBLIC_APP_URL}
84+
7785
# Per-platform cache id keeps arm64/amd64 SWC artifacts isolated.
7886
RUN --mount=type=cache,id=next-cache-${TARGETPLATFORM},target=/app/apps/sim/.next/cache \
7987
--mount=type=cache,id=turbo-cache-${TARGETPLATFORM},target=/app/.turbo \

0 commit comments

Comments
 (0)