Registry / http-networking / express-http-proxy-cp

express-http-proxy-cp

JSON →
library2.0.3jsnpmunverified

Express middleware to proxy HTTP requests to another host and pass the response back. Current stable version is 2.0.3, targeting Node 16, 18, 20. Supports streaming, Promises, and customizable request/response transforms via decorators. Key differentiators: simple API with memoizable host selection, path resolution, and body decoration; streaming by default with automatic fallback to buffering when response modifiers are used.

npm install express-http-proxy-cp
INSTALL
IMPORT
SIG · EXPRESS-HTTP-PROXY
E
express-http-proxy-cp
http-networkingjavascriptv2.0.3
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

proxy
✓ import proxy from 'express-http-proxy'
✗ const { proxy } = require('express-http-proxy')
Default export only; use default import or const proxy = require('express-http-proxy')
proxy (function)
✓ app.use('/proxy', proxy('http://example.com'))
✗ app.use('/proxy', proxy('http://example.com'))()
proxy() returns middleware; do not invoke the result.
options
✓ app.use('/proxy', proxy('host', { proxyReqOptDecorator: (req) => req }))
✗ app.use('/proxy', proxy('host', { proxyReqOptionsDecorator: (req) => req }))
Option property names are camelCase. Common misspelling: 'proxyReqOptionsDecorator' instead of 'proxyReqOptDecorator'.

Basic proxy setup with path resolution and response transformation.

const express = require('express'); const proxy = require('express-http-proxy'); const app = express(); app.use('/proxy', proxy('http://httpbin.org', { proxyReqPathResolver: (req) => '/anything' + req.url, proxyResDecorator: (proxyRes, proxyResData, userReq, userRes) => { const data = JSON.parse(proxyResData.toString('utf8')); data.transformed = true; return JSON.stringify(data); } })); app.listen(3000, () => console.log('Proxy listening on port 3000'));
Debug
Known issues
breakingRequires Node >=6.0.0; breaking change for older Node versions
fix
Upgrade Node to version 6 or higher; if stuck on older Node, use v1.x.
affects: >=2.0.0
gotchaStreaming disabled when response modifiers (userResDecorator, userResHeaderDecorator) are used; request and response are buffered
fix
Avoid response modifiers for large payloads, or accept buffering overhead.
affects: >=1.2.0
deprecatedUserResDecorator and similar hooks are deprecated in favor of proxyResDecorator and proxyResHeaderDecorator
fix
Replace userResDecorator with proxyResDecorator.
affects: >=2.0.0
gotchaBody-parser must be registered AFTER the proxy middleware, or POST body may be mutated
fix
Reorder middleware: app.use('/proxy', proxy(...)) before app.use(bodyParser...). If unavoidable, set parseReqBody: false and use proxyReqBodyDecorator.
affects: >=1.0.0
gotchaHost argument ignores path after host; use proxyReqPathResolver for full path control
fix
Set proxyReqPathResolver function to construct the full path including query string.
affects: >=1.1.0
Errors
Common errors & fixes
Cannot find module 'express-http-proxy'
Package not installed.
fix
Run npm install express-http-proxy --save
TypeError: proxy is not a function
Wrong import: using named import instead of default.
fix
Use const proxy = require('express-http-proxy') or import proxy from 'express-http-proxy'
Error: listen EADDRINUSE :::3000
Port already in use.
fix
Kill process using port 3000 or choose another port.
Cannot read property 'url' of undefined
proxyReqPathResolver called with wrong arguments; expects (req, res).
fix
Define function as (req) => { ... } and use req.url if available.
Upgrade
Version history
2.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
OpenAI (training)
1
Resources
express-http-proxy-cp — npm install express-http-proxy-cp · libregistry