Skip to content

Frontend + API behind one route

Putting your frontend and API under one origin removes CORS and makes cookies simple, the browser sees a single host. routeup can route by path so / goes to your dev server and /api/* goes to your API.

https://example-app.localhost/ -> dev server (e.g. Vite on a dynamic port)
https://example-app.localhost/api/* -> API backend (e.g. port 9080)

Both are the same origin, so the browser sends cookies to both and there is no cross-origin preflight.

Describe the path targets in config so the route is reproducible:

{
"name": "example-app",
"targets": [
{ "path": "/", "port": 5173 },
{ "path": "/api", "port": 9080 }
]
}

Then serve it:

Terminal window
routeup serve

Add --expose and the single-origin layout is preserved on the public URL too, so a deployed-style https://example-app.try.routeup.dev/api/... works without reconfiguring the frontend. A token-less hosted address is session-only; a namespace token gives the route a reusable address for later runs.

Terminal window
routeup serve --expose

This is the same one-URL model your app will use in production, which means origin-sensitive behavior shows up in development instead of after you ship.