Global HTTP/HTTPS proxy configurable using environment variables.
To configure HTTP proxy:
- Import
global-agent/bootstrap
. - Export HTTP proxy address as
GLOBAL_AGENT_HTTP_PROXY
environment variable.
Code:
import 'global-agent/bootstrap';
Bash:
$ export GLOBAL_AGENT_HTTP_PROXY=http:https://127.0.0.1:8080
Alternatively, you can preload module using Node.js --require, -r
configuration, e.g.
$ export GLOBAL_AGENT_HTTP_PROXY=http:https://127.0.0.1:8080
$ node -r 'global-agent/bootstrap' your-script.js
global-agent
is using roarr
logger to log HTTP requests.
Export ROARR_LOG=true
environment variable to enable log printing to stdout.
Use roarr-cli
program to pretty-print the logs.
global-agent
works with all libraries that internally use http.request
.
global-agent
has been tested to work with:
global-agent
works be configuring http.globalAgent
and https.globalAgent
.
global-agent
works with Node.js v12.0.0 and above.
Some libraries (e.g. request
) change their behaviour when HTTP_PROXY
environment variable is present. Using a namespaced environment variable prevents conflicting library behaviour.
global-tunnel
(and global-tunnel-ng
) are designed to support legacy Node.js versions and rely on monkey-patching http.request
, http.get
, https.request
and https.get
methods. global-agent
works by configuring http.globalAgent
.