Hostnames and HTTPS
A service with a hostname is reached over HTTPS through a proxy inside the daemon. The lane’s number is part of the domain, so each lane has hostnames of its own, and you write a hostname once in the project file for every lane.
The lane number is part of the domain
Section titled “The lane number is part of the domain”A lane’s domain is the project name under localhost, with the lane number joined to the name: myapp.localhost for lane 0 and myapp1.localhost for lane 1. Hostnames in the project file are written under that domain:
services: api: hosts: "api.${{ lane.domain }}" web: hosts: "${{ lane.domain }}"servicesLong-running processes of each lane, started together after infrastructure, setup and lane.start tasks. Each service gets its own port as PORT and, with hosts, HTTPS hostnames. A service that exits shows as failed and is not restarted.
services.<name>A long-running process started with the lane, such as a dev server or a worker. Each service gets its own port from the lane's block (PORT, ${{ self.port }}); devlanes stops it with the lane and never restarts it when it exits. A service needs run or run_script, directly or through extends.
services.<name>.hostsHostnames the devlanes HTTPS proxy routes to this service, so https://<host> reaches it. One entry or a list; an entry is a hostname or a mapping with host and optional port (a named port), fallback and host_header. A *. wildcard matches subdomains, and an exact host wins over it. The first non-wildcard host becomes public_url, non-wildcard hosts join the lane's DEVLANES_ORIGINS, and having hosts makes the default ready a TCP check. Keep them under ${{ lane.domain }} so lanes do not collide.
In lane 1 that gives api.myapp1.localhost for the API and myapp1.localhost for the web service.
Each lane is a site of its own
Section titled “Each lane is a site of its own”A browser keeps cookies per site, and under localhost a site is the label just before it. The web service at myapp1.localhost and the API at api.myapp1.localhost are one site, so a cookie the web service sets for its domain reaches the API. Lane 0 is another site and does not get it, so logging in on one branch does not log you in on another.
That is why the number goes into the name. A domain such as lane1.myapp.localhost would put every lane under the one site myapp.localhost, and opening lanes as localhost with a port would be worse, since cookies ignore the port. Set CORS and cookies for each lane builds on this.
The proxy finds the lane by the hostname
Section titled “The proxy finds the lane by the hostname”All hostnames arrive at the proxy on one port, 443 by default. The browser names the host it wants, the proxy finds the lane and service that route it, and passes the request on to that service’s port on 127.0.0.1 over plain HTTP. Your service needs no TLS of its own. A name no lane routes is refused.
When the proxy cannot have port 443, it uses another one and the URLs carry that port; Choose the proxy’s ports covers it. Plain http on port 80 redirects to HTTPS.
The devlanes CA signs each hostname
Section titled “The devlanes CA signs each hostname”The certificates come from an authority, the devlanes CA, that devlanes creates on your machine for your user, constrained to names meant for local development (Security). Your browser accepts them once the CA is trusted, which devlanes setup does (Trust the devlanes CA). Services that devlanes starts in Node, Bun, Deno, Python, Rust, Go and Java trust it, though Go on macOS and Windows relies on devlanes setup.
Hostnames under localhost resolve to your machine
Section titled “Hostnames under localhost resolve to your machine”Names ending in .localhost are reserved for the machine itself, so they need no DNS server. Browsers and most systems answer them with 127.0.0.1 by themselves. A few programs ask DNS instead, and for those devlanes can write the names to the hosts file or answer them itself; Fix programs that cannot resolve *.localhost covers it.