Localhost Just Got a Public URL: Cloudflare Tunnels in Wrangler & Vite
原定直播时间 7月25日,23:00 - GMT-4 23:30
English
转录文本 (测试版)
Using Cloudflare Tunnels, you can expose your local dev server to the Internet in one click.
This is useful when you need to share a preview, test a webhook, or access your app from another device.
Go to your local Wrangler dev server and just hit T on the keyboard.
That's it. No configuration needed. This launches a quick tunnel that's integrated into Wrangler.
It's free, it's fast, and doesn't require an account.
By default, Quick Tunnels gives you a random tryCloudflare.com domain.
If you'd like to have a static tunnel domain for your application, then you need to use Named Tunnels.
Named Tunnels are free but require a few more steps.
To set up Named Tunnels, log into your Cloudflare dashboard.
Under Networking, Tunnels, create a Named Tunnel. Head back to the Tunnels homepage and configure the created tunnel.
Head to Roots, add a root, and select the published application root.
Optionally, create a subdomain or use any root domain you own.
Then, set the service URL to the scheme and port your local dev server is running.
Finally, head back to your app and update the dev script to use the Named Tunnel.
Start the dev server and hit T and you're good to go. Everything we've just seen is supported in Brangler as well as the Cloudflare Vite plugin via DefineConfig.
Sharing local dev sessions through Cloudflare Tunnels is available in Brangler 4.92.0 and the Cloudflare Vite plugin version 1.37.1 and is completely free to use.
Go check it out. Happy building.
