Proxy: one project URL
Add a top-level proxy: block to put every service behind a single URL. Portler starts a local reverse proxy on a Portler-assigned port and prints one project URL — which also removes CORS pain, because the browser only ever talks to one origin.
yaml
proxy:
port: auto
routes:
/api: backend
/: frontendtext
$ portler up
SERVICE PORT URL
...
[portler] project url: http://localhost:52000Requests to http://localhost:52000/api/... go to backend; everything else goes to frontend.
How routing works
- The longest matching prefix wins, and matching respects path segment boundaries:
/apimatches/apiand/api/users, but not/apifoo. - The prefix is not stripped before forwarding, like most dev proxies: a request for
/api/usersreaches the backend as/api/users. Mount your routes under the same path the proxy uses. - Routes can target local and Docker services alike — the proxy forwards to their assigned localhost ports. A route must target a service that declares a
port.
Port
port: auto(or omittingport) lets Portler pick a free port.- A fixed number like
port: 8080is preferred when free — like a service's declared port, it is not a hard requirement.
Headers and WebSockets
- The
Hostheader is preserved, andX-Forwarded-For,X-Forwarded-Proto, andX-Forwarded-Hostare set. - WebSocket upgrades are proxied transparently, so dev-server HMR works through the project URL.
- When a routed service is down, the proxy answers
502 Bad Gatewaywith a message naming the service.
Lifecycle
The proxy follows the project lifecycle:
portler upstarts it (also with--detach),portler downstops it,portler down proxystops just the proxy.
It shows up as proxy in portler ports and portler ps.
Referencing the proxy
The proxy's address is available to services as PORTLER_PROXY_URL / PORTLER_PROXY_PORT, or via references like proxy.url:
yaml
services:
backend:
command: npm run dev
port: 4000
port_env: PORT
env:
PUBLIC_ORIGIN: proxy.urlWARNING
With a proxy: block present, proxy is a reserved name and cannot be used as a service name.