Open source, MIT licensed
Private HTTPS URLs for every git worktree
Each worktree's dev servers get their own addresses, such as https://api.feat-x.dev.example.com, behind a sign-in that only the people you allow can pass. Traffic goes through a tunnel server you run yourself.
- Developers
npm install --global @tafrahq/wt-tunnel-client - Whoever deploys the server
npm install --global @tafrahq/wt-tunnel
Needs Node.js 26 or later. The CLIs run on Linux and macOS; any browser that trusts your root CA can open the URLs.
- feat-x
- https://feat-x.dev.example.com
- https://api.feat-x.dev.example.com
- fix-login
- https://fix-login.dev.example.com
- https://api.fix-login.dev.example.com
Every app listens on 127.0.0.1. No ports in the URLs.
Several branches at once, one localhost
Git worktrees let you run several branches at once, but every dev server still lands on one machine.
Ports and cookies collide
Every branch lands on
localhostat some port. Ports clash, and cookies and OAuth redirects leak between branches.Sharing means a public link
Showing a branch to a teammate, a phone or a reviewer usually means a public tunnel that anyone with the link can open.
Certificates publish branch names
Public certificate authorities log every certificate in Certificate Transparency logs, so a certificate per branch publishes every branch name.
How it works
The server is one container with Caddy, frps and a sign-in service. Each worktree runs one frpc that dials out to it, so the dev machine opens no port.
*.dev.example.compoints at the server. Caddy answers with a certificate it signs on demand from your root, for hosts under your dev domains only.- Caddy asks the sign-in service about every request. Without a valid session cookie, the browser goes to the sign-in provider and back. The app never sees that cookie.
- frps hands the request to the
frpcthat registered that host name, andfrpcpasses it to the app on127.0.0.1.
Host names
<app>.<worktree>.<domain>- Every app, for example
api.feat-x.dev.example.com <worktree>.<domain>- The app named
root, for examplefeat-x.dev.example.com
What you get
Each worktree gets its own host names, behind your sign-in, on a server you run.
<app>.<worktree>
One URL per worktree and app
Run many branches side by side without port juggling. Each app gets its own host name, so cookies, OAuth redirects and CORS work as they do in production.
sign-in
Sign-in in front of every URL
Google, GitHub, Microsoft or Cloudflare Access, whichever you set up. Only the emails and email domains you allow get through, and one sign-in covers every worktree under a dev domain.
root CA
No public certificates
Dev hosts get certificates from your own root CA, name-constrained to your dev domains, so a device that trusts it trusts nothing else. Only the sign-in host appears in public logs.
frpc
No device agent, no VPN
Viewers need a browser and the root CA, trusted once. The dev machine needs no root access and opens no port: one
frpcper worktree dials out to the server.WebSocket
WebSockets pass through
WebSocket connections go through the tunnel, so Vite hot module reload works.
fly.io
One config file to deploy
wt-tunnel deploycreates the server on one Fly.io Machine fromwt-tunnel.deploy.json. It creates the DNS records in Cloudflare, or lists them for you to create.self-hosted
Self-hosted and small
The server is one container with Caddy, frps and the sign-in service. Deploy it with the CLI, or run the public image on any host.
MIT
Open source
MIT licensed. Read the code, run it and change it. Bug reports, fixes and ideas are welcome on GitHub.
Quick start
There are three roles. One person runs the server for a team, a repository adds a config file, and each developer installs the client.
Install the CLIs you need
The three CLIs are published to npm under
@tafrahq. They need Node.js 26 or later, on Linux or macOS.- Developers
npm install --global @tafrahq/wt-tunnel-client - Whoever deploys the server
npm install --global @tafrahq/wt-tunnel
- Developers
Run a server
You need a domain whose DNS you control, a Fly.io account, an OAuth client with at least one sign-in provider (Google, GitHub, Microsoft or Cloudflare Access), Node.js 26 or later, and
openssl.mkdir my-wt-tunnel && cd my-wt-tunnel wt-tunnel init # writes a commented wt-tunnel.deploy.json $EDITOR wt-tunnel.deploy.json # Fly app, hosts, dev domains, who may sign in, DNS zones export FLY_API_TOKEN=... GITHUB_CLIENT_ID=... GITHUB_CLIENT_SECRET=... # or GOOGLE_*, MICROSOFT_*, CLOUDFLARE_ACCESS_* wt-tunnel deployThe first deploy creates
.server/, which holds the server config, a new root CA and generated secrets. Back it up and never commit it. Then openhttps://auth-wt-tunnel.example.com/caon each device to trust the root.Add wt-tunnel to a project
Commit a
wt-tunnel.jsonat the repository root:{ "domain": "dev.example.com", "server": { "host": "wt-tunnel.example.com" }, "apps": { "root": { "portEnv": "PORT" }, "api": { "portEnv": "API_PORT" } } }The app labelled
rootgetshttps://<worktree>.dev.example.com, and every other app getshttps://<app>.<worktree>.dev.example.com. Dev servers must listen on127.0.0.1at the port in their variable. Vite also needsserver.allowedHosts: ['.dev.example.com'].Set up as a developer
export WT_TUNNEL_SERVER_TOKEN=... # tunnelToken from the server's .server/wt-tunnel-server.json git worktree add -b feat-x ../myapp-feat-x && cd ../myapp-feat-x wt-tunnel-client worktree add myapp feat-x eval "$(wt-tunnel-client env)" # exports PORT, API_PORT and WT_TUNNEL_HOST npx vite --host 127.0.0.1 --port "$PORT" --strictPort # for exampleTrust the root CA once per device, from the server's
/capage.wt-tunnel-client worktree removestops the tunnel and releases the ports.
See it run
Real output, with the server on the same machine and example.com names. A real setup deploys the server with wt-tunnel deploy.
