Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

proxy-agent

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

proxy-agent

Maps proxy protocols to `http.Agent` implementations

  • 6.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10M
increased by3.41%
Maintainers
1
Weekly downloads
 
Created

What is proxy-agent?

The proxy-agent npm package is a module that provides an HTTP(s) proxy Agent which can be used to proxy HTTP and HTTPS requests through a specified proxy server. This is useful in scenarios where network requests need to be routed through a proxy for reasons such as security, privacy, or circumventing network restrictions.

What are proxy-agent's main functionalities?

Creating an HTTP proxy agent

This feature allows you to create an HTTP proxy agent that will route HTTP requests through the specified proxy server.

const ProxyAgent = require('proxy-agent');
const agent = new ProxyAgent('http://proxy-server.com:8080');
const http = require('http');

const requestOptions = {
  host: 'example.com',
  port: 80,
  path: '/',
  agent: agent
};

http.get(requestOptions, (res) => {
  console.log(`Got response: ${res.statusCode}`);
});

Creating an HTTPS proxy agent

This feature allows you to create an HTTPS proxy agent that will route HTTPS requests through the specified proxy server using TLS/SSL encryption.

const ProxyAgent = require('proxy-agent');
const agent = new ProxyAgent('https://proxy-server.com:443');
const https = require('https');

const requestOptions = {
  host: 'example.com',
  port: 443,
  path: '/',
  agent: agent
};

https.get(requestOptions, (res) => {
  console.log(`Got response: ${res.statusCode}`);
});

Support for different proxy protocols

The proxy-agent package supports various proxy protocols including HTTP, HTTPS, SOCKS, and PAC (Proxy Auto-Config).

const ProxyAgent = require('proxy-agent');

const httpAgent = new ProxyAgent('http://proxy-server.com:8080');
const httpsAgent = new ProxyAgent('https://proxy-server.com:443');
const socksAgent = new ProxyAgent('socks://proxy-server.com:1080');
const pacAgent = new ProxyAgent('pac+http://proxy-server.com/proxy.pac');

// Use the appropriate agent for the request protocol

Other packages similar to proxy-agent

Keywords

FAQs

Package last updated on 25 May 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc