fix(frontend): bake relative NEXT_PUBLIC_API_URL=/api (fixes #70)#74
Open
jcschaff wants to merge 1 commit into
Open
fix(frontend): bake relative NEXT_PUBLIC_API_URL=/api (fixes #70)#74jcschaff wants to merge 1 commit into
jcschaff wants to merge 1 commit into
Conversation
The frontend image hardcoded NEXT_PUBLIC_API_URL=http://k8s-wn-01...:30001 at build time, so the browser's data/chat calls never hit the environment's own ingress. Since the ingress serves the frontend at / and the backend at /api on the same host, bake a RELATIVE "/api" instead: the browser calls the same origin it's served from, the ingress routes /api -> backend, and one image works in every environment. - frontend/Dockerfile: ARG/ENV NEXT_PUBLIC_API_URL defaulting to /api; drop the COPY .env step - build_containers.yml: pass --build-arg NEXT_PUBLIC_API_URL=/api instead of writing a hardcoded NodePort .env Fixes #70. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XpNzobVi83p3YKL9sqtGwZ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #70.
Problem
The frontend image hardcoded
NEXT_PUBLIC_API_URL=http://k8s-wn-01.cam.uchc.edu:30001at build time (it's inlined into the browser bundle), so the browser's data/chat calls never hit the environment's own ingress — they went to that fixed NodePort regardless of where the app was deployed.Fix
The ingress serves the frontend at
/and the backend at/apion the same host, so bake a relative/api. The browser then calls the same origin it's served from, the ingress routes/api → backend(stripping/api), and one image works in every environment (dev/prod/local) — no per-env images, no runtime injection.frontend/Dockerfile:ARG/ENV NEXT_PUBLIC_API_URLdefaulting to/api; dropped theCOPY .envstep (overridable with--build-arg NEXT_PUBLIC_API_URL=<absolute-url>if the frontend is ever served on a different origin than the API)..github/workflows/build_containers.yml: pass--build-arg NEXT_PUBLIC_API_URL=/apiinstead of writing a hardcoded NodePort.env.Safe because all usages are client-side
Every
NEXT_PUBLIC_API_URLreference is a browser fetch (client components); there is no SSR/server-action use, so a relative URL always resolves against the correct origin in the browser.Validation
Tag
0.1.8builds both images with the fix; the deployment PR (#73) points its overlays at0.1.8and it's verified live on the dev cluster.🤖 Generated with Claude Code
https://claude.ai/code/session_01XpNzobVi83p3YKL9sqtGwZ