Skip to content

Serve the paper wrappers' assets and manuscripts from base-path-absolute URLs - #107

Draft
MaxGhenis wants to merge 1 commit into
mainfrom
fix/wrapper-absolute-urls
Draft

MaxGhenis wants to merge 1 commit into
mainfrom
fix/wrapper-absolute-urls

Conversation

@MaxGhenis

Copy link
Copy Markdown
Contributor

policyengine.org proxies /us/snap-payment-error-simulator to this app and 308-redirects /paper/ to /paper. The wrappers therefore load from a URL with no trailing slash, and their relative URLs resolve one level too high. On policyengine.org (live check, 2026-11-27):

  • the iframe web/index.html?v=r11-20261024 resolves to /us/snap-payment-error-simulator/web/index.html: 404;
  • ../tokens.css, ../app.css and both logos resolve to /us/...: 404;
  • the PDF link resolves to /us/snap-payment-error-simulator/web/index.pdf: 404;
  • "Live simulator" (../) resolves to /us/, which redirects to policyengine.org's own /us home page rather than the simulator.

/paper-migrations has the same pattern. Its companion-paper link (../paper/) also lands outside the app, at /us/paper/.

Changes

  • Both wrappers. Every same-site URL now starts with /us/snap-payment-error-simulator/: the favicon, stylesheets, logos, iframe, standalone and PDF links, the home link and the companion-paper link. The existing vercel.json rewrites route these paths on policyengine.org and on the Vercel deployment, so vercel.json is unchanged. Every target path returns 200 on both hosts today (see Evidence).

  • tests/test_wrapper_urls.py (new). It parses the front page and both wrappers, honoring <base>. It resolves each href and src the way a browser does, from every address the page is served at:

    • policyengine.org with and without the trailing slash;
    • the Vercel deployment's bare paths.

    It maps the resulting path through vercel.json: a static file first, then the first matching rewrite, on segment boundaries. It requires a file under app/public. It also checks that each wrapper's iframe serves that wrapper's own web/index.html with a cache key, and that wrapper URLs carry the base path.

  • tests/test_paper_embed.py and tests/test_migrations_wrapper.py. Both parse the HTML instead of matching a regex. A data-src iframe or a commented-out iframe now fails. The migrations test derives the expected URL from REVISION and the qmd date, so Migrations paper revision 4: cite Wu and Meyer, describe the pooled test accurately #104 only needs to change REVISION.

Evidence

  • The new test fails on main. At 682ff6c, 8 fail and 8 pass. The failures are the slashless policyengine.org address and the bare Vercel address for each wrapper, the iframe check and the base-path check. The trailing-slash addresses pass on main, as expected: relative URLs work only there. On this branch, 16 pass.
  • The emulation matches live routing. Live results agree with the emulated misses: /us/tokens.css 404, /us/snap-payment-error-simulator/web/index.html 404, and snap-qc-sim.vercel.app/web/index.html 404. The new targets return 200 on both hosts.
  • Mutations. Each change below makes the wrapper tests fail, for both wrappers:
    • src changed to data-src on the iframe;
    • the iframe commented out;
    • tokens.css back to ../;
    • the PDF link back to web/;
    • the iframe back to web/.
  • Local runs. pytest tests/test_wrapper_urls.py tests/test_paper_embed.py tests/test_migrations_wrapper.py tests/test_retired_claims.py: 47 passed. ruff check passed at CI scope.

Not fixed here

  • The manuscripts' own assets 404, on both hosts.
    • The committed renders reference site_libs/... (/paper) and index_files/libs/... (/paper-migrations). Neither directory has ever been committed under web/. Every committed render of either manuscript references them: 14 of /paper since 2026-08-10, and 3 of /paper-migrations.
    • So the iframe now loads, but the manuscript HTML still has no Bootstrap or Quarto stylesheet. The iframe sandbox blocks scripts anyway.
    • The new test covers the pages' own URLs, not the manuscripts' internal links. This needs a render change (Document the deploy procedure and make the paper renders path-independent #99 touches the Quarto config) or copied asset folders, so it gets its own PR.
  • The /paper-migrations wrapper's copy describes the main paper. That covers its meta description, og:description, og:url (pointing to /paper/) and the header paragraph. It is a content fix for a separate PR.

Deploy

Merging deploys nothing: the site deploys by hand from app/public (d3189 is Max's deploy decision). This PR should merge before that deploy, and #104 and #105 merge main afterwards.

🤖 Generated with Claude Code

…ute URLs

policyengine.org proxies /us/snap-payment-error-simulator to this app and
redirects /paper/ to /paper, so the wrappers load from a URL with no
trailing slash. Their relative URLs then resolved one level too high: the
iframe, the PDF and standalone links, the stylesheets, the logos and the
home link all pointed outside the paper directory or outside the app, and
404ed (live check, 2026-11-27).

Every same-site URL in /paper and /paper-migrations now starts with
/us/snap-payment-error-simulator/, which vercel.json routes on both
policyengine.org and the Vercel deployment.

tests/test_wrapper_urls.py resolves each href and src on the front page
and both wrappers from every address they are served at, maps the path
through vercel.json, and requires a file under app/public. It fails on
the previous wrappers. The two wrapper tests now parse the HTML, so a
data-src or commented-out iframe no longer passes.

Co-Authored-By: Claude Opus 5.5 <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