I'm working on a dev setup for a monorepo. It contains multiple apps powered by Vite:
- An Astro app (the landing page)
- A React Router app (a web app)
In production, their build outputs are merged and requests are managed by a reverse proxy. I'd like to mirror that in my development environment (astro dev
and vite serve
respectively).
When a browser visits a URL, the path (some URLs always serve the web app, some always serve the landing page) and the cookies (signed in users are served the landing page on the /
root directory) decide which app handles the request.
Any proxy before the two apps cannot make a purely path- and header-based decision because paths like localhost/@vite/client
and localhost/@fs
are the same between the two apps.
How can I set up a development proxy that routes requests, including to Vite's internal routes, to the right app? I was looking for an option to give these paths a user-facing prefix but have not found anything.