Skip to content

Fix: pass NEXT_PUBLIC_API_URL at build time for the web image - #7

Open
mpont91 wants to merge 1 commit into
ent0n29:mainfrom
mpont91:fix/web-build-arg-api-url
Open

Fix: pass NEXT_PUBLIC_API_URL at build time for the web image#7
mpont91 wants to merge 1 commit into
ent0n29:mainfrom
mpont91:fix/web-build-arg-api-url

Conversation

@mpont91

@mpont91 mpont91 commented Aug 26, 2026

Copy link
Copy Markdown

Next.js inlines NEXT_PUBLIC_* into the client bundle when it builds. deploy/Dockerfile.web runs npm run build without the variable and only receives it at runtime, where it no longer has any effect:

ENV NEXT_TELEMETRY_DISABLED=1
RUN npm run build          # NEXT_PUBLIC_API_URL is not set here

So a deployed dashboard ships with the http://localhost:8000 fallback baked into its JavaScript, and no visitor can reach the API. Local dev hides it because docker-compose.local.yaml runs next dev, which reads the variable at request time.

Adds ARG NEXT_PUBLIC_API_URL before the build so it can be passed as a build arg:

web:
  build:
    args:
      NEXT_PUBLIC_API_URL: "https://your.domain"

Worth noting the value must not include the /api suffix — the frontend already prepends it (see #2).

Next.js inlines NEXT_PUBLIC_* into the client bundle when it builds, but the
production image runs npm run build without it and only receives the value at
runtime, where it has no effect.

The deployed dashboard therefore falls back to http://localhost:8000 and no
browser can reach the API. Local dev hides this because it runs next dev.

Adds an ARG so the value can be passed with build args.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant