Skip to content

Replace iframe with Vercel reverse proxy support#107

Merged
PavelMakarchuk merged 1 commit intomainfrom
reverse-proxy-support
Feb 17, 2026
Merged

Replace iframe with Vercel reverse proxy support#107
PavelMakarchuk merged 1 commit intomainfrom
reverse-proxy-support

Conversation

@PavelMakarchuk
Copy link
Contributor

@PavelMakarchuk PavelMakarchuk commented Feb 17, 2026

Summary

Closes #106

Prepare the tracker for a crawler-only reverse proxy on policyengine.org. Search engines and social scrapers will receive the tracker HTML directly (with proper canonical URLs, structured data, and sitemap on policyengine.org). Regular users continue to see the tracker inside the existing iframe with the full policyengine.org nav/footer — no visual change for humans.

This repo (tracker)

  • Rename Vite assetsDir from assets/ to _tracker/ to avoid path collisions with app-v2's /assets/
  • Add BASE_PATH module that detects proxied (/us/state-legislative-tracker) vs standalone routing
  • Update all pushState calls in App.jsx and StatePanel.jsx to use BASE_PATH
  • Update prerender canonical URLs, sitemap, robots.txt to point to policyengine.org
  • Update og:image to policyengine.org domain
  • Update Modal static mount from /assets to /_tracker
  • Bump APP_VERSION to v22

Companion changes needed in policyengine-app-v2

  • vercel.json: Add rewrite rules for /_tracker/:path* → Modal (assets)
  • app/middleware.ts: For crawler user-agents hitting /us/state-legislative-tracker/*, let the Vercel rewrite serve Modal HTML directly instead of the app shell. Regular users still get the iframe page.
  • No changes to iframe page or homepage — users see the same UI as before

Architecture

Crawlers:  policyengine.org/us/state-legislative-tracker/GA
           → middleware detects bot UA → passes through
           → Vercel rewrite → modal.run/GA → pre-rendered HTML with SEO tags

Users:     policyengine.org/us/state-legislative-tracker/GA
           → middleware returns app shell → iframe loads tracker as before

Assets:    policyengine.org/_tracker/index-*.js
           → Vercel rewrite → modal.run/_tracker/index-*.js

Backward compatibility

All existing URLs continue working:

  • modal.run/GA — standalone, unchanged (BASE_PATH = '')
  • policyengine.org/.../state-legislative-tracker — iframe for users, proxy for crawlers
  • Old hash URLs (#GA) — redirect logic preserved
  • All previously shared links remain valid

Deploy order

  1. This repo first → merge, deploy to Modal, verify standalone works
  2. app-v2 second → add Vercel rewrites + middleware crawler split

Test plan

  • npm run builddist/_tracker/ has JS/CSS, no dist/assets/
  • Built index.html references /_tracker/index-*.js
  • Dev server: click state → URL /GA, click bill → /GA/bill-id, back button works
  • After Modal deploy: standalone modal.run/GA still works
  • After app-v2 deploy: curl -A Googlebot .../state-legislative-tracker/GA → tracker HTML with canonical policyengine.org URL
  • After app-v2 deploy: browser visit → iframe with policyengine.org nav (unchanged)

🤖 Generated with Claude Code

Replace iframe embedding with Vercel reverse proxy architecture so that
policyengine.org/us/state-legislative-tracker/* serves tracker HTML directly
from Modal, with proper SEO canonical URLs on policyengine.org.

- Rename Vite assetsDir from assets/ to _tracker/ to avoid path collisions
- Add BASE_PATH detection for proxied vs standalone routing
- Update prerender canonical URLs, sitemap, robots.txt to policyengine.org
- Update og:image to policyengine.org domain
- Bump APP_VERSION to v22

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

Replace iframe with Vercel reverse proxy for policyengine.org integration

1 participant

Comments