wrangler dev --remote: Browser Redirects to Production URL
Hello everyone, I'm encountering an issue with wrangler dev --remote in Cloudflare Workers. In my understanding, this command should generate a temporary preview deployment with a URL in the format <VERSION_PREFIX>-<WORKER_NAME>.<SUBDOMAIN>.workers.dev. However, when I run npx wrangler dev --remote, my files upload successfully, but the browser redirects to the production URL <WORKER_NAME>.<SUBDOMAIN>.workers.dev instead of the expected preview URL. Additionally, I checked the Deploy version, but I couldn’t find the uploaded preview version.
Here’s what I’ve observed:
Command output:
✨ Success! Uploaded 9 files (74 already uploaded) (1.64 sec)
[wrangler:inf] GET / 307 Temporary Redirect (1705ms)
Browser redirect: From http://localhost:46221 to the production URL.
Wrangler version: 4.16.0
Node version: 22.16.0
I’ve verified my wrangler.toml configuration and confirmed that preview_urls = true and workers_dev = true are set. Has anyone else experienced this issue? Any insights would be greatly appreciated. Thank you!
4 Replies
wrangler dev and wrangler dev —remote just run development environment until you close your terminal. It sounds like you want to deploy a preview deployment. Maybe you are looking for the command wrangler versions uploadThank you for your reply! Perhaps my understanding is still not thorough enough. I actually wanted to use the --remote command in the development environment to access the remote database d1. When everything was ready with --remote, and I pressed b to open localhost:8787, my terminal only printed [wrangler:inf] GET / 307 Temporary Redirect (1705ms) and then redirected localhost:8787 to my workers.dev URL. This resulted in me not being able to see the page where I'm actually running the development environment, nor any terminal output. I'm unsure which step I performed incorrectly.
Oh I see, that sounds pretty normal except for the redirect happening then
Do you have a _redirects file https://developers.cloudflare.com/workers/static-assets/redirects/
Or some auth code or Cloudflare Access configured? Not sure but maybe that could cause a redirect?
Also try updating your wrangler version, maybe it’s a bug in wrangler?
Cloudflare Docs
Redirects
To apply custom redirects on a Worker with static assets, declare your redirects in a plain text file called _redirects without a file extension, in the static asset directory of your project. This file will not itself be served as a static asset, but will instead be parsed by Workers and its rules will be applied to static asset responses.
I encountered the same exact issue today, perhaps it's a bug
Did anyone managed to find a fix?