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.
npm install proxyVerified import paths — ran on the pinned version, not inferred.
This example sets up a basic HTTP(S) proxy server on port 3128 with a simple username/password authentication scheme using the `createProxy` API.
Upgrade your Node.js environment to version 20 or newer. Use a tool like `nvm` or `volta` to manage Node.js versions.
Ensure your project is configured for ESM imports where possible (`'type': 'module'` in `package.json`). If using CommonJS, verify imports work as expected or consider using dynamic `import()` if issues arise.
For production environments, implement custom authentication logic programmatically using the `server.authenticate` function, which offers more control and better security practices compared to shell-based authentication.
Verify the specified `localAddress` IP is valid and available on the host machine. Use `ipconfig` (Windows) or `ifconfig`/`ip addr` (Linux/macOS) to check network interfaces.
Change your import statement to `import { createProxy } from 'proxy';` and ensure your `package.json` has `'type': 'module'` or use a file extension like `.mjs` for your module.Either stop the conflicting process or configure the proxy server to listen on a different port using `server.listen(PORT)` in the API or the `-p`/`--port` option with the CLI tool.
Ensure the client sending requests through the proxy provides a correctly formatted `Proxy-Authorization` header with valid credentials (e.g., `Proxy-Authorization: Basic <base64_encoded_username:password>`).
No dependency data recorded yet.