Skip to content

tracker: remap /tracker/api proxy paths for standalone host#20

Merged
xrendan merged 2 commits into
mainfrom
worktree-tracker-api-rewrite-fix
May 28, 2026
Merged

tracker: remap /tracker/api proxy paths for standalone host#20
xrendan merged 2 commits into
mainfrom
worktree-tracker-api-rewrite-fix

Conversation

@xrendan
Copy link
Copy Markdown
Member

@xrendan xrendan commented May 28, 2026

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/v1 prefix) while dashboard/burndown stay under /api/. Mirror the server-side mapping already in src/lib/tracker-api.ts so client-side SWR calls land on the right endpoints when NEXT_PUBLIC_TRACKER_API_BASE is set.

Behavior is unchanged when the env var is unset (still forwards /tracker/api/* to https://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 → 200
  • GET /tracker/api/v1/commitments.json?per_page=1 → 200
  • GET /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 → 200
  • tsc --noEmit clean
  • eslint next.config.ts clean

xrendan added 2 commits May 28, 2026 10:23
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.
@xrendan xrendan merged commit 06185a8 into main May 28, 2026
1 check passed
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