Skip to content

devlanes is in beta and not ready for production use.Report an issue

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.

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:

devlanes.yaml
services:
api:
hosts: "api.${{ lane.domain }}"
web:
hosts: "${{ lane.domain }}"

In lane 1 that gives api.myapp1.localhost for the API and myapp1.localhost for the web service.

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.

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.

Lane 0, the site myapp.localhostLane 1, the site myapp1.localhostBrowserhttps://api.myapp1.localhostThe name resolves to 127.0.0.1Proxy in the daemonfinds the route and signs a certificate with the devlanes CAwebapiwebapi

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 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.