Security News
NVD Backlog Tops 20,000 CVEs Awaiting Analysis as NIST Prepares System Updates
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
superagent-proxy
Advanced tools
The superagent-proxy npm package is an extension for the SuperAgent HTTP client library that allows you to route HTTP requests through a proxy server. This can be useful for various purposes such as bypassing network restrictions, anonymizing requests, or testing applications in different network environments.
HTTP Proxy
This feature allows you to route HTTP requests through an HTTP proxy server. The code sample demonstrates how to make a GET request to 'http://example.com' through an HTTP proxy server running at 'http://proxy-server:8080'.
const superagent = require('superagent');
require('superagent-proxy')(superagent);
superagent
.get('http://example.com')
.proxy('http://proxy-server:8080')
.end((err, res) => {
if (err) {
console.error(err);
} else {
console.log(res.body);
}
});
HTTPS Proxy
This feature allows you to route HTTPS requests through an HTTPS proxy server. The code sample demonstrates how to make a GET request to 'https://example.com' through an HTTPS proxy server running at 'https://proxy-server:8080'.
const superagent = require('superagent');
require('superagent-proxy')(superagent);
superagent
.get('https://example.com')
.proxy('https://proxy-server:8080')
.end((err, res) => {
if (err) {
console.error(err);
} else {
console.log(res.body);
}
});
SOCKS Proxy
This feature allows you to route HTTP requests through a SOCKS proxy server. The code sample demonstrates how to make a GET request to 'http://example.com' through a SOCKS proxy server running at 'socks5://proxy-server:1080'.
const superagent = require('superagent');
require('superagent-proxy')(superagent);
superagent
.get('http://example.com')
.proxy('socks5://proxy-server:1080')
.end((err, res) => {
if (err) {
console.error(err);
} else {
console.log(res.body);
}
});
Axios is a promise-based HTTP client for the browser and Node.js. It supports making requests through a proxy by configuring the proxy settings in the request options. Compared to superagent-proxy, Axios is more widely used and has built-in support for proxies without needing an additional package.
Request is a simplified HTTP client for Node.js with support for proxies. It allows you to configure proxy settings directly in the request options. Although the request package is deprecated, it is still widely used and offers similar proxy functionalities as superagent-proxy.
Node-fetch is a lightweight module that brings window.fetch to Node.js. It supports making requests through a proxy by using the 'http-proxy-agent' or 'https-proxy-agent' packages. Compared to superagent-proxy, node-fetch requires additional configuration for proxy support but is a minimalistic and modern alternative.
Request#proxy(uri)
superagent extensionThis module extends visionmedia/superagent
's Request
class with
a .proxy(uri)
function. This allows you to proxy the HTTP request through a
proxy of some kind.
It is backed by the proxy-agent
module, so see
its README for more details.
Install with npm
:
$ npm install superagent-proxy
var request = require('superagent');
// extend with Request#proxy()
require('superagent-proxy')(request);
// HTTP, HTTPS, or SOCKS proxy to use
var proxy = process.env.http_proxy || 'http://168.63.43.102:3128';
request
.get(process.argv[2] || 'https://encrypted.google.com/')
.proxy(proxy)
.end(onresponse);
function onresponse (res) {
console.log(res.status, res.headers);
console.log(res.body);
}
(The MIT License)
Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
`Request#proxy(uri)` superagent extension
We found that superagent-proxy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.