How it works
dcp is two independent pieces that end at the same app: a local HTTPS proxy for *.localhost names, and the online
links: a path-routing proxy behind one Tailscale entry, and, when you turn it on, a host router behind a Cloudflare
Tunnel.
A browser on your Mac opens https://api.acme.localhost; the dcp proxy on port 443 passes the request to the app on 127.0.0.1:4417. A Stripe webhook, your phone or a teammate opens https://bigfoot.tail1234.ts.net/api/; Tailscale Funnel ends TLS on your Mac and dcp sends /api/ to the same app.
The local side (the boot service, the route files, the certificate authority) is described in Local HTTPS names. This page covers the online side.
Online: architecture
One Tailscale entry terminates TLS and forwards plain HTTP to the local dcp
proxy, which routes by the first path segment to the matching dev server.
Discovery pipeline
Every --interval seconds:
- List listeners — TCP sockets in
LISTENwithin the port range, with PID (macOS/Linux vialsof+ps, Windows vianetstat+tasklist). On macOS/Linux, process details (runtime path, working directory, project root) are cached per PID, so an idle re-scan spawns a singlelsof. - Classify runtime from the executable name (
node,bun,deno,python/uvicorn/gunicorn,ruby/puma,php,go run,java,dotnet,elixir,docker-proxy, …). - Slug = the nearest project-root folder name (markers:
package.json,.git,go.mod,pyproject.toml,Cargo.toml,mix.exs, …). - Resolve duplicates — within one project folder the process on the lowest
port is the main service (clean, port-free slug); any other process in the same
folder gets a
-<port>suffix so it stays reachable. A single process on several ports collapses to its lowest port. Distinct projects sharing a folder name also get a-<port>suffix to stay unique.
Routing
For /<segment>/<rest…>?<query>:
- Hit → forward to
http://127.0.0.1:<port>/<rest…>(segment stripped,Hostrewritten tolocalhost). Streaming flushes immediately; WebSocket upgrades are relayed. - Miss / empty →
404listing the registered services. - Dead backend →
502.
Slugs are canonically dash-separated. With --match-separators (on by default),
an exact miss is retried with _ folded to -, so /module_api_foo/ and
/module-api-foo/ reach the same server. --match-separators=false routes only
the exact dash form.
Cookie route-affinity
Apps assume they live at the root, so their HTML references absolute paths
(/_next/..., /api/..., HMR). When you open …/<slug>/, dcp sets a
dcp_route cookie pinning that browser tab to the project, so prefix-less requests
follow it to the right backend — and the page renders exactly like localhost.
Lifecycle
- Sharing is on by default and lives in the local HTTPS proxy, so it starts at boot, survives worker swaps (the entry stays; the next worker carries on) and comes back after a Tailscale restart within seconds.
- A
RouteStoreis refreshed on a ticker. A service missing from discovery is kept forderegisterCyclesscans before removal (no flapping on restarts). - Without the boot service,
dcp startruns the same pieces in a terminal; onCtrl-Cthe server drains andtailscale serve|funnel resetruns before exit — never leaving a Funnel pointing at a dead port. - A single bounded
http.Transportkeeps connections to dev servers from accumulating.
Online: Cloudflare
With cloudflare on, the local HTTPS proxy keeps three things in place, next to the Tailscale entry:
- A tunnel named
dcp-<machine>, managed from Cloudflare's side. Its one ingress rule sends everything to dcp's host router on127.0.0.1:<port+1>, which picks the app by hostname and presents the request as a local one, path unchanged. - One proxied CNAME per app,
<app>-<machine>.<zone>→<tunnel-id>.cfargotunnel.com, with the commentdcp <machine>. dcp deletes only records that point at its own tunnel and refuses a hostname that already has a record it did not make. - The connector,
cloudflared, started with the tunnel's token in its environment and restarted when it exits.
The tunnel, its ingress and DNS are checked every 5 minutes and whenever the set of apps changes; the tunnel's health
every 30 seconds. Turning Cloudflare off stops the connector and keeps the tunnel and DNS, so it comes back fast;
dcp cloudflare off --purge deletes them. Setup and the token: Cloudflare.