{"library":"proxy","title":"Node.js HTTP Proxy Server","description":"The `proxy` package provides a programmatic HTTP(S) proxy server API for Node.js, allowing developers to script custom proxy logic. Its current stable version is `4.0.0`, which notably raised the minimum Node.js requirement to version 20. The project maintains an active release cadence, with recent updates across its associated `proxy-agent` ecosystem, ensuring compatibility and improvements. Key differentiators include its simple `createProxy` API for building custom proxy servers, similar to established solutions like Squid or Privoxy, but integrated directly within a Node.js environment. It supports both standard HTTP proxying and the HTTP `CONNECT` method for tunneling. The package also includes a companion CLI tool for quick server spawning.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install proxy"],"cli":{"name":"proxy","version":null}},"imports":["import { createProxy } from 'proxy';","import * as http from 'http';","import { ProxyServer } from 'proxy/dist/types';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import * as http from 'http';\nimport { createProxy } from 'proxy';\n\nconst server = createProxy(http.createServer());\n\n// Basic authorization example (replace with real auth for production)\nserver.authenticate = function (req, fn) {\n  const auth = req.headers['proxy-authorization'];\n  if (auth && auth.startsWith('Basic ')) {\n    const credentials = Buffer.from(auth.slice(6), 'base64').toString().split(':');\n    const [username, password] = credentials;\n    if (username === 'user' && password === 'password') {\n      return fn(null, true);\n    }\n  }\n  fn(null, false);\n};\n\nserver.listen(3128, () => {\n  const address = server.address();\n  const port = typeof address === 'string' ? address : address?.port;\n  console.log('HTTP(s) proxy server listening on port %d', port);\n});","lang":"typescript","description":"This example sets up a basic HTTP(S) proxy server on port 3128 with a simple username/password authentication scheme using the `createProxy` API.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}