💡 A mechanism to retrieve the currently running quick tunnels
Describe the feature you'd like When you startup a quick tunnel, it's difficult to access the current URL for that tunnel. This makes it difficult to create dev scripts using tunnels.
Describe alternatives you've considered Shopify's CLI uses tunnels as part of their development workflow, but the only way it looks like they could accomplish this was from parsing the log stream: https://github.com/Shopify/cli/blob/f74d9909f4c7ffbc9d7b7a1af17d7cd5f3d8cf8c/packages/plugin-cloudflare/src/tunnel.ts#L207-L210
Additional context
As part of multiple applications, I wanted to have a script that would startup a development environment (i.e. npm dev) and have that script startup a Cloudflare Quick Tunnel and open the URL in the default web browser. It can be difficult to determine the correct URL to open.
@davidbarratt You can query the cloudflared metrics port for the QuickTunnel URL. We will update our developer docs with this info. http://localhost:<METRICS_PORT>/quicktunnelurl
@janani-cr I would really like to be able to retrieve the URL too, but I am a bit unsure how to retrieve it. When I start my tunnel:
cloudflared tunnel --url localhost:8080
It starts my metrics server on: 127.0.0.1:60246/metrics.
Trying to access your URL returns 404: 127.0.0.1:60246/quicktunnelurl
The same happens when using the --hello-world tunnel.
What am I doing wrong?
(Cloudflared version: cloudflared version 2024.7.1 (built 2024-07-16T15:24:52Z))
For anyone in the future, the endpoint to get the URL is http://127.0.0.1:<metrics_port>/quicktunnel. If this ever stops working, check this line https://github.com/cloudflare/cloudflared/blob/2feccd772c7bfe37e43531cf7524deb30190de8b/metrics/metrics.go#L81
Response from this endpoint is a JSON object with a key of hostname and the value being the URL
Thank y'all so much for this! This is perfect ❤️