Skip to content

Commit 734207d

Browse files
committed
Inject proxy into Node 10+ using global-agent
1 parent b44bf18 commit 734207d

File tree

4 files changed

+102
-2
lines changed

4 files changed

+102
-2
lines changed

overrides/path/node

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# Exclude ourselves from PATH within this script, to avoid recursing
5+
PATH="${PATH/`dirname $0`:/}"
6+
7+
# Call node with the given arguments, prefixed with our extra logic
8+
if command -v winpty >/dev/null 2>&1; then
9+
winpty node -r "`dirname $0`/node_modules/global-agent/bootstrap" "$@"
10+
else
11+
node -r "`dirname $0`/node_modules/global-agent/bootstrap" "$@"
12+
fi

package-lock.json

Lines changed: 87 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"async-mutex": "^0.1.3",
3636
"command-exists": "^1.2.8",
3737
"env-paths": "^1.0.0",
38+
"global-agent": "^1.12.2",
3839
"graphql": "^14.0.2",
3940
"graphql-yoga": "^1.16.7",
4041
"lodash": "^4.17.11",

src/interceptors/fresh-terminal.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ export class TerminalInterceptor implements Interceptor {
251251
'HTTP_PROXY': `http://localhost:${proxyPort}`,
252252
'https_proxy': `http://localhost:${proxyPort}`,
253253
'HTTPS_PROXY': `http://localhost:${proxyPort}`,
254+
// Used by global-agent to configure node.js HTTP(S) defaults
255+
'GLOBAL_AGENT_HTTP_PROXY': `http://localhost:${proxyPort}`,
254256
// Used by some CGI engines to avoid 'httpoxy' vulnerability
255257
'CGI_HTTP_PROXY': `http://localhost:${proxyPort}`,
256258

0 commit comments

Comments
 (0)