{"id":17226,"library":"express-request-proxy","title":"Express Request Proxy","description":"express-request-proxy is an Express.js middleware designed for creating high-performance streaming HTTP reverse proxies. It enables features like transparent caching via Redis, server-side injection of sensitive API keys and headers, custom route parameter handling, and response transformations. The package is built upon the widely used, but now deprecated, `request` HTTP client library. Its last major release was 2.x, with version 2.2.2 being the latest. Given its dependency on the unmaintained `request` library and lack of recent updates (last commit August 2018), the package is effectively abandoned, limiting its viability for new projects and posing potential maintenance and security risks.","status":"abandoned","version":"2.2.2","language":"javascript","source_language":"en","source_url":"https://github.com/dvonlehman/express-request-proxy","tags":["javascript","express","middleware","request","api","proxy"],"install":[{"cmd":"npm install express-request-proxy","lang":"bash","label":"npm"},{"cmd":"yarn add express-request-proxy","lang":"bash","label":"yarn"},{"cmd":"pnpm add express-request-proxy","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core HTTP client for proxying. This library is officially deprecated and unmaintained, making express-request-proxy inherit its security and stability issues.","package":"request","optional":false},{"reason":"Required for enabling the caching functionality within the proxy middleware.","package":"redis","optional":true},{"reason":"Extends the node_redis client with stream-based functionality essential for express-request-proxy's caching mechanism.","package":"redis-streams","optional":true}],"imports":[{"note":"This package is CommonJS only and relies on the deprecated 'request' library. Attempting ES module imports will result in errors. There are no named exports.","wrong":"import requestProxy from 'express-request-proxy';","symbol":"requestProxy","correct":"const requestProxy = require('express-request-proxy');"}],"quickstart":{"code":"const express = require('express');\nconst redis = require('redis');\nconst requestProxy = require('express-request-proxy');\nrequire('redis-streams')(redis); // Extend redis client with streams functionality\n\nconst app = express();\nconst port = 3000;\n\n// Create a Redis client for caching\nconst redisClient = redis.createClient();\nredisClient.on('error', (err) => console.error('Redis Client Error', err));\n\n// Connect to Redis (async operation)\nasync function connectRedis() {\n  await redisClient.connect();\n  console.log('Connected to Redis');\n}\nconnectRedis();\n\napp.get(\n  '/api/:resource/:id',\n  requestProxy({\n    cache: redisClient, // Use the connected Redis client\n    cacheMaxAge: 60, // Cache for 60 seconds\n    url: 'https://jsonplaceholder.typicode.com/:resource/:id', // Example public API\n    query: {\n      api_key: process.env.SOMEAPI_SECRET_KEY ?? 'demo-key' // Inject sensitive key from env\n    },\n    headers: {\n      'X-Custom-Auth': process.env.SOMEAPI_CUSTOM_HEADER ?? 'secret-value' // Inject custom header\n    }\n  })\n);\n\napp.get('/', (req, res) => {\n    res.send('Proxy server running. Try /api/posts/1 or /api/users/2');\n});\n\napp.listen(port, () => {\n  console.log(`Proxy server listening at http://localhost:${port}`);\n  console.log('Test with: curl http://localhost:3000/api/posts/1');\n});","lang":"javascript","description":"This quickstart demonstrates setting up an Express server to use `express-request-proxy` to forward requests to a public API, including server-side injection of API keys and custom headers, and utilizing Redis for caching responses."},"warnings":[{"fix":"Migrate to a modern proxy solution based on 'node-fetch', 'axios', 'undici', or 'http-proxy-middleware'.","message":"The core dependency, 'request' library, has been officially deprecated and is no longer maintained. This means 'express-request-proxy' inherits significant security vulnerabilities, stability issues, and lack of future updates. Using this package in production is highly discouraged.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Use 'const requestProxy = require(\"express-request-proxy\");' for importing the middleware.","message":"This package is CommonJS (CJS) only. Attempting to import it using ES module syntax (e.g., 'import requestProxy from \"express-request-proxy\"') will lead to runtime errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure you call 'require(\"redis-streams\")(redis);' after requiring the 'redis' package and before creating the client used by the proxy. Also ensure the redis client is connected before passing it.","message":"The caching feature relies on a 'redis' client that must be extended with 'redis-streams'. Incorrect setup (e.g., missing 'require(\"redis-streams\")(redis);') will prevent caching from working or cause runtime errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Define environment variables in your deployment environment or use a package like 'dotenv' to load them before your application script runs.","message":"Environment variables for sensitive keys (e.g., 'SOMEAPI_SECRET_KEY') must be set in the server environment before the application starts, as 'express-request-proxy' accesses them directly via 'process.env'.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consider migrating to a contemporary proxy solution that uses modern HTTP clients for better maintainability and performance.","message":"The 'request' library, which this package is built upon, is deprecated. Its API patterns (e.g., callback-based) are outdated compared to modern promise-based or async/await HTTP clients, affecting code maintainability and future compatibility.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Change your import statement to CommonJS: 'const requestProxy = require(\"express-request-proxy\");'","cause":"Attempting to use ES module import syntax (e.g., 'import') for a CommonJS-only package.","error":"TypeError: requestProxy is not a function"},{"fix":"Ensure 'request' is listed in your package.json and installed. However, due to its deprecation, it's strongly recommended to migrate away from this package.","cause":"The 'request' dependency might be missing, or there are module resolution issues related to its deprecation and potential removal from package managers.","error":"Error: Cannot find module 'request'"},{"fix":"Verify your Redis server is running and configured correctly. Check the host and port in 'redis.createClient()' options, and ensure `redisClient.connect()` has been called and awaited.","cause":"The Redis server is not running or is inaccessible at the configured host/port, or the client was not connected before being passed to the proxy.","error":"Redis Client Error connect ECONNREFUSED"},{"fix":"Ensure the 'url' option is always provided in the 'requestProxy' configuration object, as it is the only required option.","cause":"The configuration object passed to 'requestProxy' is invalid or incomplete, preventing it from returning a valid Express middleware function. Most commonly, the 'url' option is missing.","error":"TypeError: app.use() requires middleware functions but got a [object Object]"}],"ecosystem":"npm","meta_description":null}