cloudflare / cloudflared

Cloudflare Tunnel client (formerly Argo Tunnel)
https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/tunnel-guide
Apache License 2.0
8.79k stars 775 forks source link

💡 A mechanism to retrieve the currently running quick tunnels #1256

Open davidbarratt opened 3 months ago

davidbarratt commented 3 months ago

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.

janani-cr commented 3 months ago

@davidbarratt You can query the cloudflared metrics port for the QuickTunnel URL. We will update our developer docs with this info. http://localhost:/quicktunnelurl

JanmanX commented 1 month ago

@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))