tracker: remap /tracker/api proxy paths for standalone host#20
Merged
Conversation
The Next rewrite blindly forwarded /tracker/api/v1/* to <base>/tracker/api/v1/*, which 404s on the standalone Outcome Tracker host (commitments/departments live at the root, no /api/v1 prefix). Mirror the server-side mapping in lib/tracker-api.ts so client-side SWR calls work against the nelson deploy via NEXT_PUBLIC_TRACKER_API_BASE.
The var is only read server-side (next.config.ts rewrites + lib/tracker-api.ts), and the upstream URL is never exposed to the browser via the proxy. The NEXT_PUBLIC_ prefix was misleading. Consolidate on a single TRACKER_API_BASE env var.
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.
Summary
The
/tracker/api/*Next rewrite blindly forwarded paths to<base>/tracker/api/*, which 404s on the standalone Outcome Tracker host (nelson deploy). On the standalone host, commitments/departments live at the root (no/api/v1prefix) while dashboard/burndown stay under/api/. Mirror the server-side mapping already insrc/lib/tracker-api.tsso client-side SWR calls land on the right endpoints whenNEXT_PUBLIC_TRACKER_API_BASEis set.Behavior is unchanged when the env var is unset (still forwards
/tracker/api/*tohttps://www.buildcanada.com/tracker/api/*).This is needed because
https://www.buildcanada.com/tracker/api/*currently returns Cloudflare error 1000 ("DNS points to prohibited IP") — separate infra issue, but local dev needs the nelson upstream regardless. The upstream host stays server-side; the browser only ever sees/tracker/api/....Test plan
Verified locally with
NEXT_PUBLIC_TRACKER_API_BASE=https://outcomes-tracker.nelson.canadasbuilding.com npx next dev:GET /tracker/api/v1/departments.json→ 200GET /tracker/api/v1/commitments.json?per_page=1→ 200GET /tracker/api/v1/commitments/3323.json→ 200 (single-commitment path)GET /tracker/api/dashboard/1/at_a_glance→ 200 (preserves/api/)GET /tracker/api/burndown/1→ 200tsc --noEmitcleaneslint next.config.tsclean