Gathering detailed insights and metrics for proxy-http-agent
Gathering detailed insights and metrics for proxy-http-agent
Gathering detailed insights and metrics for proxy-http-agent
Gathering detailed insights and metrics for proxy-http-agent
http-proxy-agent
An HTTP(s) proxy `http.Agent` implementation for HTTP
https-proxy-agent
An HTTP(s) proxy `http.Agent` implementation for HTTPS
socks-proxy-agent
A SOCKS proxy `http.Agent` implementation for HTTP and HTTPS
proxy-agent
Maps proxy protocols to `http.Agent` implementations
A factory to create http proxy agent! Based on the tunnel module! To use a proxy through modules like http and https or node-fetch! It support https => (http, https) and http => (http, https). (proxy => server) ! Either the proxy is http and either it will go as a tunnel for http! Or a tunnel for https through the CONNECT method! Or the proxy will be https! And direct forwarding will go!
npm install proxy-http-agent
Typescript
Module System
Node Version
NPM Version
TypeScript (99.57%)
JavaScript (0.43%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
1 Stars
4 Commits
3 Forks
1 Watchers
1 Branches
3 Contributors
Updated on Nov 01, 2023
Latest Version
1.0.1
Package Id
proxy-http-agent@1.0.1
Unpacked Size
9.98 kB
Size
3.24 kB
File Count
6
NPM Version
6.14.8
Node Version
12.4.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
2
A factory to create http proxy agent! Based on the tunnel module! To use a proxy through modules like http and https or node-fetch!
It support https => (http, https) and http => (http, https). (proxy => server) ! Either the proxy is http and either it will go as a tunnel for http! Or a tunnel for https through the CONNECT method! Or the proxy will be https! And direct forwarding will go!
1npm install proxy-http-agent --save
The name start with proxy and make the accent on https agent to highlight that it's https.Agent
1let agent = getProxyHttpAgent(options);
1const { getProxyHttpAgent } = require('proxy-http-agent'); 2 3let proxyUrl = 4 process.env.HTTP_PROXY || 5 process.env.http_proxy || 6 `http://localhost:${proxyPort}`; 7 8let agent = getProxyHttpAgent({ 9 proxy: proxyUrl, 10 rejectUnauthorized: false 11});
Also the module is build by typescript! It support typescript too out of the box!
1import { getProxyHttpAgent } = from 'proxy-http-agent'; 2import https from 'https'; 3 4let proxyUrl = 5 process.env.HTTP_PROXY || 6 process.env.http_proxy || 7 `http://localhost:${proxyPort}`; 8 9let agent: https.Agent = getProxyHttpAgent({ 10 proxy: proxyUrl, 11 rejectUnauthorized: false 12});
In the core the options are the direct options of http.Agent
and https.Agent
and tunnel module factories options
Check the node-tunnel repo here
https://github.com/koichik/node-tunnel/
Plus our extra options:
(Obligatory)
1interface IProxyOptions { 2 host: string; 3 port: number; 4 protocol?: 'http:' | 'https:'; 5 localAddress?: string; 6 proxyAuth?: string; 7 headers?: { [key: string]: any }; 8}
1interface IHttpsProxyOptions extends IProxyOptions { 2 ca?: Buffer[]; 3 servername?: string; 4 key?: Buffer; 5 cert?: Buffer; 6}
string: the proxy url
(optional) default: 'https:'
For typescript you can also get directly https.Agent type from this module as follow
1import { getProxyHttpAgent, HttpsAgent, HttpAgent } = from 'proxy-http-agent'; 2 3let proxyUrl = 4 process.env.HTTP_PROXY || 5 process.env.http_proxy || 6 `http://localhost:${proxyPort}`; 7 8let agent: HttpsAgent = getProxyHttpAgent({ 9 proxy: proxyUrl, 10 rejectUnauthorized: false 11});
We do expose and export it too.
From the test files here some nice examples
(default is https)
1let proxyUrl =
2 process.env.HTTP_PROXY ||
3 process.env.http_proxy ||
4 `http://localhost:${proxyPort}`;
5
6let agent = getProxyHttpAgent({
7 proxy: proxyUrl, // proxy as url string! We can use an object (as tunnel module require too)
8 rejectUnauthorized: false
9});
10
11try {
12 console.log(('fetch :::: :: :: :: :'))
13 const response = await fetch(`https://localhost:${localApiHttpsServerPort}`, {
14 method: 'GET',
15 agent
16 });
17
18 console.log('"response !!!!!!!!!!!!"')
19
20 if (response.status === 200) {
21 const data = await response.json();
22
23 console.log(data)
24
25 if (data) {
26 expect(data.host).toEqual(`localhost:${localApiHttpsServerPort}`);
27 } else {
28 fail(new Error('No data from local server!'));
29 }
30 }
31} catch(err) {
32 fail(err);
33}
1let proxyUrl = 2 process.env.HTTP_PROXY || 3 process.env.http_proxy || 4 `http://localhost:${proxyPort}`; 5 6let agent = getProxyHttpAgent({ 7 proxy: proxyUrl 8}); 9 10const opts: any = url.parse(`https://api.binance.com/api/v3/ping`); 11delete opts.port; 12opts.agent = agent; 13 14let req = https.get(opts, function(res) { 15 let data: any = ''; 16 res.setEncoding('utf8'); 17 res.on('data', function(b) { 18 console.log('::::::::::::::::::::::::::::::::::::://///>') 19 console.log('DATA ::::') 20 data += b; 21 }); 22 res.on('end', function() { 23 console.log('RESPONSE END :::::::::::////>') 24 data = JSON.parse(data); 25 26 console.log(data) 27 28 expect(data).toEqual({}); 29 done(); 30 }); 31}); 32req.once('error', done);
1let proxyUrl =
2 process.env.HTTP_PROXY ||
3 process.env.http_proxy ||
4 `http://localhost:${proxyPort}`;
5
6let agent = getProxyHttpAgent({
7 proxy: proxyUrl,
8 endServerProtocol: 'http:' // <<==== here (we precise that we need an agent to communicate with an end server that work with http)
9});
10
11try {
12 console.log("Fetch ::::>")
13 const response = await fetch(`http://localhost:${localApiServerPort}`, {
14 method: 'GET',
15 agent
16 });
17
18 console.log('response :::::::::////>')
19
20 if (response.status === 200) {
21 const data = await response.json();
22
23 if (data) {
24 expect(data.host).toEqual(`localhost:${localApiServerPort}`);
25 } else {
26 fail(new Error('No data from local server!'));
27 }
28 }
29} catch(err) {
30 fail(err);
31}
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
3 existing vulnerabilities detected
Details
Reason
no SAST tool detected
Details
Reason
Found 0/4 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More