Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Global HTTP/HTTPS proxy agent configurable using environment variables.
| Date | Stars |
|---|---|
| 2026-07-31 | 417 |
| 2026-08-03 | 417 |
| 2026-08-06 | 417 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
# global-agent
[](https://www.npmjs.org/package/global-agent)
[](https://github.com/gajus/canonical)
[](https://twitter.com/kuizinas)
Global HTTP/HTTPS proxy configurable using environment variables.
* [Usage](#usage)
* [Setup proxy using `global-agent/bootstrap`](#setup-proxy-using-global-agentbootstrap)
* [Setup proxy using `bootstrap` routine](#setup-proxy-using-bootstrap-routine)
* [Runtime configuration](#runtime-configuration)
* [Exclude URLs](#exclude-urls)
* [API](#api)
* [`createGlobalProxyAgent`](#createglobalproxyagent)
* [Environment variables](#environment-variables)
* [`global.GLOBAL_AGENT`](#globalglobal_agent)
* [Supported libraries](#supported-libraries)
* [FAQ](#faq)
* [What is the reason `global-agent` overrides explicitly configured HTTP(S) agent?](#what-is-the-reason-global-agent-overrides-explicitly-configured-https-agent)
* [What is the reason `global-agent/bootstrap` does not use `HTTP_PROXY`?](#what-is-the-reason-global-agentbootstrap-does-not-use-http_proxy)
* [What is the difference from `global-tunnel` and `tunnel`?](#what-is-the-difference-from-global-tunnel-and-tunnel)
## Usage
### Setup proxy using `global-agent/bootstrap`
To configure HTTP proxy:
1. Import `global-agent/bootstrap`.
1. Export HTTP proxy address as `GLOBAL_AGENT_HTTP_PROXY` environment variable.
Code:
```js
import 'global-agent/bootstrap';
// or:
// import {bootstrap} from 'global-agent';
// bootstrap();
```
Bash:
```bash
$ export GLOBAL_AGENT_HTTP_PROXY=http://127.0.0.1:8080
```
Alternatively, you can preload module using Node.js `--require, -r` configuration, e.g.
```bash
$ export GLOBAL_AGENT_HTTP_PROXY=http://127.0.0.1:8080
$ node -r 'global-agent/bootstrap' your-script.js
```
### Setup proxy using `bootstrap` routine
Instead of importing a self-initialising script with side-effects as demonstrated in the [setup proxy using `global-agent/bootstrap`](#setup-proxy-using-global-agentbootstrap) documentation, you can import `bootstrap` routine and explicitly evaluate the bootstrap logic, e.g.
```js
import {
bootstrap
} from 'global-agent';
bootstrap();
```
This is useful if you need to conditionally bootstrap `global-agent`, e.g.
```js
import {
bootstrap
} from 'global-agent';
import globalTunnel from 'global-tunnel-ng';
const MAJOR_NODEJS_VERSION = parseInt(process.version.slice(1).split('.')[0], 10);
if (MAJOR_NODEJS_VERSION >= 10) {
// `global-agent` works with Node.js v10 and above.
bootstrap();
} else {
// `global-tunnel-ng` works only with Node.js v10 and below.
globalTunnel.initialize();
}
```
### Setup proxy using `createGlobalProxyAgent`
If you do not want to use `global.GLOBAL_AGENT` variable, then you can use `createGlobalProxyAgent` to instantiate a controlled instance of `global-agent`, e.g.
```js
import {
createGlobalProxyAgent
} from 'global-agent';
const globalProxyAgent = createGlobalProxyAgent();
```
Unlike `bootstrap` routine, `createGlobalProxyAgent` factory does not create `global.GLOBAL_AGENT` variable and does not guard against multiple initializations of `global-agent`. The result object of `createGlobalProxyAgent` is equivalent to `global.GLOBAL_AGENT`.
### Runtime configuration
`global-agent/bootstrap` script copies `process.env.GLOBAL_AGENT_HTTP_PROXY` value to `global.GLOBAL_AGENT.HTTP_PROXY` and continues to use the latter variable.
You can override the `global.GLOBAL_AGENT.HTTP_PROXY` value at runtime to change proxy behaviour, e.g.
```js
http.get('http://127.0.0.1:8000');
global.GLOBAL_AGENT.HTTP_PROXY = 'http://127.0.0.1:8001';
http.get('http://127.0.0.1:8000');
global.GLOBAL_AGENT.HTTP_PROXY = 'http://127.0.0.1:8002';
```
The first HTTP request is goingExcerpt of 12,030 characters
Read on GitHubWould you bet a product on this? Bounded 0–100 and slow moving.
Not classified yet. Classification runs as part of npm run ingest.