global-agent is a Node.js library designed to globally configure HTTP/HTTPS proxy settings for outgoing network requests. It intercepts `http.Agent` and `https.Agent` instances to route traffic through a specified proxy server, configurable primarily via environment variables such as `GLOBAL_AGENT_HTTP_PROXY`, `GLOBAL_AGENT_HTTPS_PROXY`, and `GLOBAL_AGENT_NO_PROXY`. The current stable version is 4.1.3, released in March 2026, indicating an active development and maintenance status. The project maintains a steady release cadence, with multiple minor and patch updates in early 2026. Key differentiators include its simple bootstrap mechanism for seamless global integration across applications, support for dynamic runtime re-configuration of proxy settings, and its intentional design to override other explicitly configured HTTP agents. It distinguishes itself by primarily using its own set of environment variables rather than strictly adhering to the standard `HTTP_PROXY` convention for its main bootstrap module.
npm install global-agentVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to enable global HTTP/HTTPS proxying using the side-effect import and environment variables, then makes a sample HTTP request.
To allow connections to servers with self-signed certificates, set the environment variable `GLOBAL_AGENT_SKIP_HTTPS_VALIDATION=true`. Be aware of the security implications of disabling certificate validation.
Always use `GLOBAL_AGENT_HTTP_PROXY`, `GLOBAL_AGENT_HTTPS_PROXY`, and `GLOBAL_AGENT_NO_PROXY` environment variables for configuration when using the bootstrap mechanism.
Be aware that `global-agent` will likely supersede other proxy configurations. If you need fine-grained control over specific requests, consider using `createGlobalProxyAgent` to get a controlled instance or disable `global-agent` for those specific parts of your application.
Update your import statements to use named exports: `import { bootstrap } from 'global-agent';` or `import { createGlobalProxyAgent } from 'global-agent';`.Set `GLOBAL_AGENT_SKIP_HTTPS_VALIDATION=true` in your environment variables to bypass certificate validation. Use with caution as it disables security checks. For production, ensure your proxy uses trusted certificates or configure your system to trust the self-signed certificate.
Export `GLOBAL_AGENT_HTTP_PROXY` (e.g., `export GLOBAL_AGENT_HTTP_PROXY=http://localhost:8080`) instead of `HTTP_PROXY`.
Ensure `import 'global-agent/bootstrap';` or `bootstrap();` is only executed once. If using conditional logic, wrap it carefully or use `createGlobalProxyAgent` for non-global instances.
Switch to ES module import syntax: `import { bootstrap } from 'global-agent';`. Ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json` or `.mjs` file extension).No dependency data recorded yet.