Automatic Cloudflare quick tunnel for devspace serve + styled startup UI#16
Open
prestonlogan wants to merge 1 commit into
Open
Automatic Cloudflare quick tunnel for devspace serve + styled startup UI#16prestonlogan wants to merge 1 commit into
devspace serve + styled startup UI#16prestonlogan wants to merge 1 commit into
Conversation
DevSpace currently requires the user to stand up their own public tunnel or reverse proxy and paste the resulting URL during `devspace init`. This adds an opt-in "Automatic Cloudflare quick tunnel" mode so `devspace serve` can expose itself publicly on its own, plus a clack-styled startup summary that matches the existing setup screens. What's new: - src/cloudflare-tunnel.ts: locate `cloudflared` (PATH, then ~/.devspace/bin), auto-install the official release when missing, start `cloudflared tunnel --url`, and scrape the https://*.trycloudflare.com URL from its output. Honors CLOUDFLARED_BIN; all process spawns use shell:false. - `devspace init` now asks how the host should be reached: automatic Cloudflare tunnel (persists `tunnel: "cloudflare"`) or a manual public URL (unchanged). - `devspace serve` starts the tunnel when enabled, sets DEVSPACE_PUBLIC_BASE_URL so the tunnel hostname is added to the Host allowlist, prints a styled summary box, and tears the tunnel down on SIGINT/SIGTERM/exit. - Per-run overrides: `--tunnel` / `--no-tunnel` flags and DEVSPACE_TUNNEL env. - Help text and config type (`DevspaceUserConfig.tunnel`) updated. Security note: the cloudflared binary is downloaded over HTTPS from the official cloudflare/cloudflared releases and smoke-tested with `--version`, but is not checksum-pinned (trust-on-first-use, same model as running it from PATH). Happy to add SHA-256 verification if preferred. Verified: `npm run typecheck`, `npm run build`, and `npm test` all pass; tunnel start/URL-capture/teardown exercised end to end.
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.
What this adds
Today
devspace initrequires the user to stand up their own tunnel/reverse proxy and paste the public URL by hand. This PR adds an opt-in "Automatic Cloudflare quick tunnel" mode sodevspace servecan expose itself publicly on its own — no second terminal, no manual URL — plus a clack-styled startup summary that matches the existing setup screens.It's fully opt-in and the manual-URL flow is unchanged.
Behavior
devspace initnow asks how the host should be reached:"tunnel": "cloudflare"inconfig.jsondevspace servewhen the tunnel is enabled:cloudflaredfromPATH, then~/.devspace/bin, auto-installing the official release if missing.cloudflared tunnel --url http://<host>:<port> --no-autoupdateand captures thehttps://<random>.trycloudflare.comURL.DEVSPACE_PUBLIC_BASE_URLso the tunnel hostname is added to the Host-header allowlist via the existingloadConfig()path.SIGINT/SIGTERM/exit.Per-run overrides:
devspace serve --tunnel/--no-tunnel, orDEVSPACE_TUNNEL=cloudflare|none.CLOUDFLARED_BINpoints at a specific binary.Example
Files
src/cloudflare-tunnel.ts(new) — cloudflared resolve/install + quick-tunnel lifecycle. All spawns useshell: false.src/cli.ts— init tunnel-mode prompt, tunnel-awareserve(), styled output,--tunnel/--no-tunnel, help text.src/user-config.ts—DevspaceUserConfig.tunnel?: "cloudflare".Security considerations
spawn/spawnSynccalls useshell: falsewith array args; the only interpolated value (localBaseUrl) is built from validated config and passed as a single argv element — no shell/arg injection.0o700.https://[a-z0-9-]+\.trycloudflare\.com), so only a real trycloudflare hostname can be set, and only that exact host is added to the allowlist (no wildcard). OAuth owner-password approval is unchanged.cloudflaredis fetched over HTTPS from the officialcloudflare/cloudflaredreleases and smoke-tested with--version, but is not checksum-pinned (trust-on-first-use — the same trust model as runningcloudflaredfromPATH). Glad to add SHA-256 verification if you'd prefer.Testing
npm run typecheck,npm run build,npm testall pass.Happy to adjust naming, defaults (e.g. keep it strictly flag-gated rather than persisted), or split the styled-UI change into its own PR if you'd rather keep this focused on the tunnel.