fix: set API_BASE_URL at Docker build time for Next.js inlining

Next.js replaces process.env.X with build-time values via
DefinePlugin, even in server-side route handlers. Without
the env var set during build, it always falls back to
localhost:8000 which doesn't work inside Docker.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-02-21 22:59:47 -08:00
parent e5dcfa6113
commit 28131491e2
1 changed files with 5 additions and 0 deletions

View File

@ -8,6 +8,11 @@ RUN npm ci
COPY . . COPY . .
# Set API_BASE_URL at build time so Next.js inlines the correct value
# (Next.js replaces process.env.X at build time via DefinePlugin)
ARG API_BASE_URL=http://api-gateway:8000
ENV API_BASE_URL=${API_BASE_URL}
RUN npm run build RUN npm run build
# ===== Production ===== # ===== Production =====