Skip to content

[Feature]: Support --base-url in t3 pair for externally proxied servers #13582

Closed

Description

@davzucky

Problem

t3 pair can generate a terminal QR code using the discovered server address or configure Tailscale Serve with --tailscale, but it does not accept an explicit public URL.

My use case is running T3 inside a DevPod container while Tailscale Serve runs on the host. The host exposes a stable HTTPS tailnet URL and proxies to a forwarded container port. The container hostname/IP can change, and Tailscale is intentionally not installed inside the container.

Plain t3 pair advertises the local/container address, while t3 pair --tailscale assumes it can manage Tailscale on the machine where the command runs.

Requested behavior

Allow an explicit public base URL when generating the pairing link and terminal QR code:

t3 pair \
  --base-dir /path/to/t3-data \
  --base-url https://my-host.my-tailnet.ts.net

The command should still discover the running local server and mint its pairing token, but use the supplied URL for the advertised connection address, pairing link, and QR code. It should not configure Tailscale or change the server bind address; proxy setup remains the responsibility of the user.

This would also support other reverse proxies and SSH-forwarded deployments.

Existing workaround

t3 auth pairing create --base-url https://my-host.my-tailnet.ts.net already supports an explicit public URL, but does not offer the same terminal QR output as t3 pair. Users must render the resulting link separately, for example with qrencode.

Related issues

This request is specifically to expose an explicit --base-url override in t3 pair, consistent with t3 auth pairing create.

Activity

  1. juliusmarminge commented on Sep 25, 2026

    @juliusmarminge
    Member

    Triage: #13582

    Verdict: Accept
    Type: Feature request
    Duplicate: No
    Already implemented: No
    Confidence: High
    Suggested labels: enhancement, accepted
    Scope: Small. One CLI flag on t3 pair, tests, and a short docs note. No server, auth, or protocol change.

    What was asked

    t3 pair can print a QR for the discovered local address, or it can run tailscale serve and print the MagicDNS HTTPS URL. It cannot take an explicit public URL.

    The reporter runs T3 inside a DevPod container. Tailscale Serve runs on the host and proxies a stable https://…ts.net URL to a forwarded container port. The container address changes, and Tailscale is intentionally not installed in the container, so t3 pair --tailscale is the wrong tool. They want:

    t3 pair \
      --base-dir /path/to/t3-data \
      --base-url https://my-host.my-tailnet.ts.net

    Discovery and token minting stay against the running local server. The supplied URL is used only for the pairing link and QR. The command must not configure Tailscale or change the bind address.

    What the code does today

    t3 pair (apps/server/src/cli/pair.ts) only has --base-dir, --ttl, --label, --tailscale, and --tailscale-serve-port. There is no --base-url.

    Discovery is already separate from the advertised URL. discoverPairTarget reads server-runtime.json, checks the pid, and probes state.origin. The advertised URL is chosen afterward:

    • --tailscale calls resolveTailscalePairingBase, which reads MagicDNS and may run tailscale serve.
    • Otherwise resolveDirectPairingBaseUrl uses state.devUrl or resolveHeadlessConnectionString(state.host, state.port).
    • A loopback result adds the note to re-run with --tailscale or restart with a reachable --host.

    The QR and Pairing URL: line both come from buildPairingUrl in apps/server/src/startupAccess.ts. The header still prints the discovered local origin (Pairing with <label> (<origin>)).

    t3 auth pairing create --base-url is a real workaround and a real gap. apps/server/src/cli/auth.ts passes the flag into formatIssuedPairingCredential, which prints Pair URL:. That formatter does not render a QR (renderTerminalQrCode is only used by t3 pair and headless t3 serve). It also does not discover a live server or confirm the process is answering. It only writes a token into the CLI auth database. So the workaround matches the URL override and misses the reason t3 pair exists.

    No --tailscale-serve-host or other public-URL override exists in the tree. The only base-url flag under apps/server/src/cli is the one on t3 auth pairing create.

    Not a duplicate

    No other open issue or PR adds --base-url to t3 pair.

    Implementation notes

    Keep discovery as it is. After discoverPairTarget succeeds, if --base-url is set, use that string as pairingBaseUrl and skip resolveTailscalePairingBase entirely.

    • Reject combining --base-url with --tailscale. One advertises a user-owned proxy; the other mutates Tailscale Serve.
    • Require an absolute http: or https: URL. Do not let a bad value throw an uncaught TypeError from new URL.
    • Do not probe the public URL before printing. In the DevPod case the container often cannot hairpin to the host proxy, and a required probe would fail the exact setup this flag is for. Reachability stays the user's responsibility, same as t3 auth pairing create --base-url.
    • Skip the loopback note when the supplied host is not loopback. Keep it if they explicitly pass a loopback URL.
    • Leave the header origin as the discovered local server so it is obvious which process received the token. Put the public URL only in the QR and Pairing URL: line.
    • Reuse buildPairingUrl. It sets pathname to /pair, so a base URL with a path prefix loses that prefix. The requested URL has no path. formatIssuedPairingCredential does the same via new URL("/pair", baseUrl). Treat the flag as an origin, not a subpath mount.
    • For a dev server, /pair is on the web origin, not the API port. Help text should say the URL must reach the same origin the client will open.

    Tests belong next to the existing pair URL tests in apps/server/src/cli/pair.test.ts: the QR and pairing URL use the override, the loopback note is absent for a public host, an invalid URL fails, and --tailscale is not invoked. Document the flag in docs/user/remote-access.md beside the existing t3 pair / t3 pair --tailscale examples.

    Risks

    The QR will contain a one-time token aimed at whatever host the user typed. That is the same exposure as the existing auth command. A wrong URL sends the token to the wrong host. Do not try to fix that by probing.

    This does not fix #8384. t3 serve will still print a container address when bound to 0.0.0.0.

  2. added
    via-triage
    enhancement
    accepted
    on Sep 25, 2026
  3. tpetr commented on Oct 1, 2026

    @tpetr

    Thanks for raising this! I ran into the same problem with T3 in a Coder workspace: T3 listens on localhost, while Coder exposes it at a public URL through its reverse proxy. The proposed t3 pair --base-url option would solve one-off pairing.

    One additional behavior I’d find useful is a server-level public URL setting, so startup pairing output and plain t3 pair use that URL by default. The CLI option could still override it for an individual link. Local discovery and the bind address would stay unchanged.

    I started a prototype of the server-level setting before finding this issue and the PR. I’m not asking to expand or delay the current PR, but would a separate follow-up be welcome? I’d be happy to adapt my work if useful.

  4. SpyrosPsarras commented on Oct 7, 2026

    @SpyrosPsarras

    Another case for the server-level setting tpetr describes: T3 running headless in a Kubernetes pod behind an ingress. The server binds 0.0.0.0 in the pod, so the startup pairing link and t3 pair (run through kubectl exec) both advertise the pod IP. That IP changes on every restart and clients can't reach it. --base-url covers one-off links, but the deployment already knows its public URL, so setting T3CODE_PUBLIC_URL once in the pod spec would fix every link the server prints. #7569 asks for the same thing.

    @juliusmarminge, would a follow-up PR for --public-url / T3CODE_PUBLIC_URL on serve/start be in scope?

  5. locked and limited conversation to collaborators on Oct 11, 2026
  6. converted this issue into a discussion #18006 on Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedenhancementvia-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions