Edit: I edited the issue title since this thread has been evolved about how to inject CF env vars into a hot reloading dev server, the actual issue is further down: #5315 (comment)
Which Cloudflare product(s) does this pertain to?
Pages
What version(s) of the tool(s) are you using?
3.35.0
What version of Node are you using?
v20.11.1
What operating system and version are you using?
Ubuntu 22.04.2 LTS
Describe the Bug
Observed behavior
When the app redirects wrangler pages dev does the redirect but the URL in the browser's URL bar doesn't change (or redirect's header lacks the redirect status and new URL and the response header lacks a location header.
This is a big problem because it breaks relative links on redirected pages and doesn't reflect production.
Expected behavior
A proper redirect with URL change and proper headers
Steps to reproduce
git clone https://github.com/newsve/wrangler-no-redirect.git
npm i
npm run dev
In your browser go first to localhost:5713 which is the og SvelteKit/Vite server without wrangler, you see a redirect happng to localhost:5713/some-random-page. Now try the same with localhost:8788 which is via wrangler, still redirects but the URL in the URL bar does not change.
Also check and compare the headers (left: 5713, right 8788), note that the 8788 one lacks a response location header:

Please provide a link to a minimal reproduction
git clone https://github.com/newsve/wrangler-no-redirect.git
Please provide any relevant error logs
No response