Skip to content

Commit abb4bd7

Browse files
committed
Intercept traffic from the Go CLI
1 parent 515a55f commit abb4bd7

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/interceptors/terminal/terminal-env-overrides.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,24 @@ export function getTerminalEnvVars(
2020
httpsConfig: HttpsPathOptions,
2121
currentEnv: { [key: string]: string | undefined } | 'runtime-inherit'
2222
): { [key: string]: string } {
23+
const proxyUrl = `http://127.0.0.1:${proxyPort}`;
24+
2325
return {
24-
'http_proxy': `http://127.0.0.1:${proxyPort}`,
25-
'HTTP_PROXY': `http://127.0.0.1:${proxyPort}`,
26-
'https_proxy': `http://127.0.0.1:${proxyPort}`,
27-
'HTTPS_PROXY': `http://127.0.0.1:${proxyPort}`,
26+
'http_proxy': proxyUrl,
27+
'HTTP_PROXY': proxyUrl,
28+
'https_proxy': proxyUrl,
29+
'HTTPS_PROXY': proxyUrl,
2830
// Used by global-agent to configure node.js HTTP(S) defaults
29-
'GLOBAL_AGENT_HTTP_PROXY': `http://127.0.0.1:${proxyPort}`,
31+
'GLOBAL_AGENT_HTTP_PROXY': proxyUrl,
3032
// Used by some CGI engines to avoid 'httpoxy' vulnerability
31-
'CGI_HTTP_PROXY': `http://127.0.0.1:${proxyPort}`,
33+
'CGI_HTTP_PROXY': proxyUrl,
3234
// Used by npm, for versions that don't support HTTP_PROXY etc
33-
'npm_config_proxy': `http://127.0.0.1:${proxyPort}`,
34-
'npm_config_https_proxy': `http://127.0.0.1:${proxyPort}`,
35+
'npm_config_proxy': proxyUrl,
36+
'npm_config_https_proxy': proxyUrl,
3537
// Stop npm warning about having a different 'node' in $PATH
3638
'npm_config_scripts_prepend_node_path': 'false',
39+
// Proxy used by the Go CLI
40+
'GOPROXY': proxyUrl,
3741

3842
// Trust cert when using OpenSSL with default settings
3943
'SSL_CERT_FILE': httpsConfig.certPath,

0 commit comments

Comments
 (0)