Skip to content

new tunnel

Terminal window
holocron new tunnel --name sentinel-dev --hostname sentinel-dev.theholocron.dev --port 3000
holocron new tunnel --name sentinel-dev --hostname sentinel-dev.theholocron.dev --port 3000 --run

A GitHub App’s webhook URL has to stay the same for the App’s life, and a quick cloudflared tunnel changes its address every time it starts. A named tunnel has a stable hostname. This command sets one up in one idempotent run:

  1. The tunnels provider finds the tunnel by --name or makes it, and makes it serve --hostname at http://localhost:<port>. Routes for other hostnames on the tunnel are kept.
  2. The dns provider points a proxied CNAME for the hostname at the tunnel.
  3. It prints the address (https://<hostname>), which is what to give new github-app as the webhook URL (plus the app’s path, /api/webhook for Sentinel).

With --run it then starts cloudflared tunnel run in the foreground and stops it on Ctrl-C. The tunnel’s token reaches cloudflared through the TUNNEL_TOKEN environment variable, never its arguments (which ps shows to every user) and never the output. Without --run it only sets things up and prints the command to start it. cloudflared must be installed (brew install cloudflared).

A second run changes nothing that is already right. --dry-run says what it would do and calls nothing.

Option Default What it does
--name (required) The tunnel’s name. A second run finds the first one’s tunnel by it.
--hostname (required) The public hostname the tunnel serves.
--port 3000 The local port requests are sent to.
--run off Run the tunnel in the foreground once it is set up.

It needs a tunnels and a dns provider in the holocron.config.ts of the directory it runs in (the Cloudflare plugin offers both when it has an account id), and a Cloudflare token with Cloudflare Tunnel: Edit (account) as well as the DNS permission. holocron doctor shows how many tunnels the token can see.

providers: {
dns: ["cloudflare", { accountId: "..." }],
tunnels: ["cloudflare", { accountId: "..." }],
}