Launch hosted captun.sh tunnels#16
Merged
Merged
Conversation
This was referenced May 23, 2026
commit: |
This was referenced May 26, 2026
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
There are 4 total unresolved issues (including 2 from previous reviews).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ead1f28. Configure here.
mmkal
added a commit
that referenced
this pull request
May 26, 2026
## Summary Fast-follow for #16 review comments. - lets hosted apex `captun-connect` requests reach the tunnel gateway before the apex-to-www redirect runs - adds a hosted Worker regression test that an apex WebSocket connect gets a 101 upgrade - updates the remote smoke script to pick the standalone public tunnel URL line instead of the last URL in the CLI log, which can be the local target ## Verification - `pnpm exec vitest run test/hosted-worker.test.ts` - `pnpm run check` - `pnpm test` - `pnpm run build` <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Small routing guard and test/smoke-script tweaks; no auth, data, or broad architectural changes. > > **Overview** > **Apex tunnel connects** on `captun.sh` now bypass the hosted site handler (including the apex→www redirect) when `captun-connect=1` is present, so WebSocket upgrades hit the tunnel gateway first. A hosted Worker test asserts that behavior returns **101**. > > The **remote smoke** script infers the public tunnel URL from log lines that are standalone `http(s)://…` URLs (trimmed), instead of grabbing the last URL anywhere in the log—which could be the local target. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 9742d22. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Adds the hosted
captun.shpath so a first-time user can get a public tunnel without deploying anything first.# with something listening on localhost:3000 npx captun 3000The CLI now defaults to the hosted
https://captun.shgateway when there is no local config, generates a random tunnel name, and prints a public URL like:No Cloudflare account, config file, token, or deploy wizard is needed for that first run. Users can still run
npx captun deploylater if they want their own self-hosted gateway.What Changed
https://captun.shgatewaycreateCaptunTunnelto connect with{ gateway, name, token, fetch }and wait for the gateway to return{ url, token }acceptFetcherCapabilityandacceptFetcherCapabilityFromSocketgateway/tokensrc/worker.ts, with the hostedcaptun.shproduct surface isolated undersrc/hosted/www.captun.sh, and redirects the apex host towwwCONTEXT.mdand ADR-0001 to keep the Fetcher Capability / Tunnel / Gateway language clear#20 is superseded by this shape; hosted rate limiting and ownership controls are rebuilt in #22 on top of the gateway-owned protocol.
Library Example
Self-hosted use now passes the gateway URL, not a tunnel URL template:
npx captun 3000 --gateway 'https://captun.youraccount.workers.dev' --token abc123Structure
src/index.tscontains the client API and low-level Fetcher Capability helpers.src/worker.tsis the deployable self-hosted Cloudflare Tunnel Gateway.src/hosted/site.tsandsrc/hosted/worker.tsare the Iterate-operated hosted surface forcaptun.sh.wrangler.jsoncis for self-hosted deployment;wrangler.hosted.jsoncis for the hosted service.Verification
pnpm run checkpnpm testpnpm run buildpnpm exec vitest run test/worker.test.ts test/e2e.test.ts examples/weather-reporter/e2e.test.tsCAPTUN_PUBLIC_E2E=1 pnpm exec vitest run test/public-hosted.test.tscaptun-publicto Iterate prd withcaptun.sh/*and*.captun.sh/*