feat: add tunnel support (ngrok, Cloudflare Tunnel)#104
Open
sergical wants to merge 1 commit intovercel-labs:mainfrom
Open
feat: add tunnel support (ngrok, Cloudflare Tunnel)#104sergical wants to merge 1 commit intovercel-labs:mainfrom
sergical wants to merge 1 commit intovercel-labs:mainfrom
Conversation
Support external tunnel providers for exposing local dev servers to the internet. Three levels of integration: 1. Single-app passthrough: when one app is running, non-.localhost Host headers (from tunnel forwarding) auto-route to the single app. 2. Hostname aliasing: `portless tunnel map/unmap/list` maps external tunnel hostnames to portless routes for multi-app setups. 3. Managed tunnels: `--tunnel ngrok` or `--tunnel cloudflare` starts the tunnel alongside the app, auto-registers the alias, and sets PORTLESS_TUNNEL_URL on the child process. Closes vercel-labs#43
|
@sergical is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
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 support for external tunnel providers (ngrok, Cloudflare Tunnel) to expose local dev servers to the internet. Closes #43.
Session trace: https://www.traces.com/s/jn7c9rx9wqywxp9a77b265qtg582p96p
What changed
Three levels of integration, each independently useful:
1. Single-app passthrough (zero config)
When one app is running and a request arrives with a non-
.localhostHost header (e.g. from ngrok forwarding), portless auto-routes it to the single registered app. This means the simplest tunnel workflow just works:2. Hostname aliasing (
portless tunnel map/unmap/list)For multi-app setups, explicitly map an external tunnel hostname to a portless route:
Aliases are stored in
aliases.jsonin the state directory and watched for changes by the proxy.3. Managed tunnels (
--tunnelflag)Portless can start the tunnel for you, auto-register the alias, and pass the tunnel URL to the child process:
The child process receives
PORTLESS_TUNNEL_URLalongside the existingPORTLESS_URL. Tunnel cleanup (process kill + alias removal) happens automatically on exit.Files changed
proxy.tsfindRoute()extended with alias lookup + tunnel passthrough fallbacktypes.tsgetAliasestoProxyServerOptionsroutes.tsloadAliases,addAlias,removeAlias,removeAliasesForRoutetunnel.tsTunnelProvider/TunnelInstanceinterfaces, ngrok + cloudflare providerscli.ts--tunnelflag,PORTLESS_TUNNELenv var,handleTunnelcommand, alias watching in proxy startupindex.tstunnel.tsREADME.mdSKILL.mdproxy.test.ts,routes.test.ts,tunnel.test.ts,cli.test.tsTesting