{"id":18335,"library":"express-http-proxy-cp","title":"express-http-proxy","description":"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.","status":"active","version":"2.0.3","language":"javascript","source_language":"en","source_url":"git://github.com/villadora/express-http-proxy","tags":["javascript","express-http-proxy"],"install":[{"cmd":"npm install express-http-proxy-cp","lang":"bash","label":"npm"},{"cmd":"yarn add express-http-proxy-cp","lang":"bash","label":"yarn"},{"cmd":"pnpm add express-http-proxy-cp","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export only; use default import or const proxy = require('express-http-proxy')","wrong":"const { proxy } = require('express-http-proxy')","symbol":"proxy","correct":"import proxy from 'express-http-proxy'"},{"note":"proxy() returns middleware; do not invoke the result.","wrong":"app.use('/proxy', proxy('http://example.com'))()","symbol":"proxy (function)","correct":"app.use('/proxy', proxy('http://example.com'))"},{"note":"Option property names are camelCase. Common misspelling: 'proxyReqOptionsDecorator' instead of 'proxyReqOptDecorator'.","wrong":"app.use('/proxy', proxy('host', { proxyReqOptionsDecorator: (req) => req }))","symbol":"options","correct":"app.use('/proxy', proxy('host', { proxyReqOptDecorator: (req) => req }))"}],"quickstart":{"code":"const express = require('express');\nconst proxy = require('express-http-proxy');\nconst app = express();\n\napp.use('/proxy', proxy('http://httpbin.org', {\n  proxyReqPathResolver: (req) => '/anything' + req.url,\n  proxyResDecorator: (proxyRes, proxyResData, userReq, userRes) => {\n    const data = JSON.parse(proxyResData.toString('utf8'));\n    data.transformed = true;\n    return JSON.stringify(data);\n  }\n}));\n\napp.listen(3000, () => console.log('Proxy listening on port 3000'));","lang":"javascript","description":"Basic proxy setup with path resolution and response transformation."},"warnings":[{"fix":"Upgrade Node to version 6 or higher; if stuck on older Node, use v1.x.","message":"Requires Node >=6.0.0; breaking change for older Node versions","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Avoid response modifiers for large payloads, or accept buffering overhead.","message":"Streaming disabled when response modifiers (userResDecorator, userResHeaderDecorator) are used; request and response are buffered","severity":"gotcha","affected_versions":">=1.2.0"},{"fix":"Replace userResDecorator with proxyResDecorator.","message":"UserResDecorator and similar hooks are deprecated in favor of proxyResDecorator and proxyResHeaderDecorator","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Reorder middleware: app.use('/proxy', proxy(...)) before app.use(bodyParser...). If unavoidable, set parseReqBody: false and use proxyReqBodyDecorator.","message":"Body-parser must be registered AFTER the proxy middleware, or POST body may be mutated","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set proxyReqPathResolver function to construct the full path including query string.","message":"Host argument ignores path after host; use proxyReqPathResolver for full path control","severity":"gotcha","affected_versions":">=1.1.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run npm install express-http-proxy --save","cause":"Package not installed.","error":"Cannot find module 'express-http-proxy'"},{"fix":"Use const proxy = require('express-http-proxy') or import proxy from 'express-http-proxy'","cause":"Wrong import: using named import instead of default.","error":"TypeError: proxy is not a function"},{"fix":"Kill process using port 3000 or choose another port.","cause":"Port already in use.","error":"Error: listen EADDRINUSE :::3000"},{"fix":"Define function as (req) => { ... } and use req.url if available.","cause":"proxyReqPathResolver called with wrong arguments; expects (req, res).","error":"Cannot read property 'url' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}