Skip to content

Proxy /uk/data.json so student-loan-visualisation figures render#1054

Merged
vahid-ahmadi merged 2 commits into
mainfrom
fix/student-loan-visualisation-data-json
May 26, 2026
Merged

Proxy /uk/data.json so student-loan-visualisation figures render#1054
vahid-ahmadi merged 2 commits into
mainfrom
fix/student-loan-visualisation-data-json

Conversation

@vahid-ahmadi
Copy link
Copy Markdown
Contributor

Summary

/uk/student-loan-visualisation rendered with empty figures and an empty decile table. Root cause: the source HTML at student-loan-visualisation.vercel.app does fetch('./data.json'). Under the multizone rewrite at /uk/student-loan-visualisation (no trailing slash), the relative URL resolves to /uk/data.json → 404, so the D3 charts and table never get data.

A trailing-slash redirect doesn't work — Next.js's default trailingSlash: false auto-strips it (verified: GET /uk/student-loan-visualisation/ → 308 → no slash).

This adds a one-line afterFiles rewrite proxying /uk/data.jsonstudent-loan-visualisation.vercel.app/data.json. A more durable fix is to give the source repo an absolute path or basePath: '/uk/student-loan-visualisation', at which point this hot-patch can be removed.

The diff looks larger than the change because Prettier reformatted neighboring rewrites onto multiple lines. The only behavioral change is the new /uk/data.json entry in afterFiles.

Test plan

  • After deploy, load https://policyengine.org/uk/student-loan-visualisation and confirm Figures 1–3 and the decile table populate
  • DevTools → Network → data.json request returns 200 with the JSON payload
  • Other multizone-embedded apps (Utah, Keep Your Pay Act, Scotland income tax, etc.) still load correctly

🤖 Generated with Claude Code

The source HTML at student-loan-visualisation.vercel.app does
fetch('./data.json'). Under the multizone rewrite at
/uk/student-loan-visualisation (no trailing slash), the relative URL
resolves to /uk/data.json, which 404s — so the D3 figures and the
decile table never get data. Adding the trailing slash isn't viable
because Next.js's default trailingSlash:false auto-strips it.

This adds an afterFiles rewrite proxying /uk/data.json to the source.
A more durable fix is to give the source repo an absolute path or a
basePath, at which point this hot-patch can be removed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
policyengine-app-v2 Ready Ready Preview, Comment May 26, 2026 10:07am
policyengine-calculator Ready Ready Preview, Comment May 26, 2026 10:07am
policyengine-calculator-next Ready Ready Preview, Comment May 26, 2026 10:07am
policyengine-website Ready Ready Preview, Comment May 26, 2026 10:07am

Request Review

JSON data proxies (like /uk/data.json → student-loan-visualisation/data.json)
have no HTML layout to install gtag into, so the audit's gtag check
doesn't apply. Same rationale as the existing .svg/.css/.js skip list.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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