cloudflare / cloudflare/workers-sdk
🐛 BUG: Proxy environment variables didn't work.
- Dominant language
- TypeScript
- Stars
- 4.5k
- Forks
- 1.5k
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 186
Description
### Which Cloudflare product(s) does this pertain to?
Wrangler core, Miniflare
### What version(s) of the tool(s) are you using?
3.17.1
### What version of Node are you using?
18.16.0
### What operating system are you using?
Linux
### Describe the Bug
When debugging locally, I need to make the fetch go through a proxy, but during actual testing, I found out that it is not going through the proxy.
```
❯ uname -a
Linux youxam-Ubuntu 6.2.0-37-generic #38~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Nov 2 18:01:13 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
❯ cat worker.ts
export interface Env {
}
export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise {
const ip = await fetch("https://ipinfo.io/json?token=c31843916e5fd7")
console.log(await ip.json())
return new Response('Hello World!');
},
};
❯ https_proxy=http://127.0.0.1:7890 curl https://ipinfo.io/json\?token\=c31843916e5fd7
{
"ip": "124.244.179.246",
"hostname": "124244179246.ctinets.com",
"city": "Hong Kong",
"region": "Central and Western",
"country": "HK",
"loc": "22.2783,114.1747",
"org": "AS9269 Hong Kong Broadband Network Ltd.",
"timezone": "Asia/Hong_Kong"
}
❯ https_proxy=http://127.0.0.1:7890 wrangler dev
Proxy environment variables detected. We'll use your proxy for fetch requests.
⛅️ wrangler 3.17.1
-------------------
⎔ Starting local server...
[mf:inf] Ready on http://*:8787
[mf:inf] - http://127.0.0.1:8787
[mf:inf] - http://10.117.253.152:8787
[mf:inf] - http://localhost:8787
[mf:inf] - http://[::1]:8787
{
ip: 'xxx.xxx.xxx.xxx',
city: 'Beijing',
region: 'Beijing',
country: 'CN',
loc: 'xxx',
org: 'xxx',
timezone: 'Asia/Shanghai'
}
```
### Please provide a link to a minimal reproduction
_No response_
### Please provide any relevant error logs
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.