Skip to content

Commit 7e2e97b

Browse files
authored
feat: implement proxy support (#1051)
* feat: implement proxy support prefer lower-case http proxy env vars * Create calm-oranges-walk.md update calm-oranges-walk.md * chore: bump undici to get bug fix for http_proxy * fix: default fetch to application/json unless otherwise provided * Revert "fix: default fetch to application/json unless otherwise provided" This reverts commit 338759b. * chore: bump undici
1 parent 81d4ab3 commit 7e2e97b

File tree

4 files changed

+28
-9
lines changed

4 files changed

+28
-9
lines changed

.changeset/calm-oranges-walk.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
feat: add support for using wrangler behind a proxy
6+
7+
Configures the undici library (the library wrangler uses for `fetch`) to send all requests via a proxy selected from the first non-empty environment variable from "https_proxy", "HTTPS_PROXY", "http_proxy" and "HTTP_PROXY".

package-lock.json

+8-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/wrangler/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
"timeago.js": "^4.0.2",
9898
"tmp-promise": "^3.0.3",
9999
"ts-dedent": "^2.2.0",
100-
"undici": "^4.15.1",
100+
"undici": "^5.3.0",
101101
"update-check": "^1.5.4",
102102
"ws": "^8.5.0",
103103
"yargs": "^17.4.1"

packages/wrangler/src/index.tsx

+12
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { render } from "ink";
1111
import React from "react";
1212
import onExit from "signal-exit";
1313
import supportsColor from "supports-color";
14+
import { setGlobalDispatcher, ProxyAgent } from "undici";
1415
import makeCLI from "yargs";
1516
import { version as wranglerVersion } from "../package.json";
1617
import { fetchResult } from "./cfetch";
@@ -78,6 +79,17 @@ const resetColor = "\x1b[0m";
7879
const fgGreenColor = "\x1b[32m";
7980
const DEFAULT_LOCAL_PORT = 8787;
8081

82+
const proxy =
83+
process.env.https_proxy ||
84+
process.env.HTTPS_PROXY ||
85+
process.env.http_proxy ||
86+
process.env.HTTP_PROXY ||
87+
undefined;
88+
89+
if (proxy) {
90+
setGlobalDispatcher(new ProxyAgent(proxy));
91+
}
92+
8193
function getRules(config: Config): Config["rules"] {
8294
const rules = config.rules ?? config.build?.upload?.rules ?? [];
8395

0 commit comments

Comments
 (0)