{"id":16182,"library":"proxy-middleware","title":"Connect Proxy Middleware","description":"proxy-middleware offers a basic HTTP(S) proxy capability designed as middleware for the Connect framework. It enables developers to configure specific URL paths that forward incoming requests to an alternate target URL, supporting both HTTP and HTTPS protocols. The package's latest stable version is 0.15.0. It integrates directly into the Connect framework, a popular Node.js web framework from an earlier era. Given its age (last updated in 2016), the package is effectively abandoned, meaning it receives no further updates, security patches, or feature enhancements. This significantly limits its utility and makes it unsuitable for new projects or production environments in modern Node.js ecosystems, which have moved towards more feature-rich and actively maintained alternatives like `http-proxy-middleware` or `node-http-proxy`.","status":"abandoned","version":"0.15.0","language":"javascript","source_language":"en","source_url":"https://github.com/andrewrk/connect-proxy","tags":["javascript","connect","proxy","middleware","https","http","ssl"],"install":[{"cmd":"npm install proxy-middleware","lang":"bash","label":"npm"},{"cmd":"yarn add proxy-middleware","lang":"bash","label":"yarn"},{"cmd":"pnpm add proxy-middleware","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core web framework dependency for which this package provides middleware.","package":"connect","optional":false}],"imports":[{"note":"This package is CommonJS-only. Attempting to import it using ES module syntax will lead to runtime errors.","wrong":"import proxy from 'proxy-middleware';","symbol":"proxy","correct":"const proxy = require('proxy-middleware');"},{"note":"The main functionality is exposed as the default CommonJS export (a function). There are no named exports.","wrong":"import { proxyMiddleware } from 'proxy-middleware';","symbol":"proxyMiddleware(options)","correct":"const proxy = require('proxy-middleware');\n// ... then use proxy(options)"}],"quickstart":{"code":"const connect = require('connect');\nconst url = require('url');\nconst proxy = require('proxy-middleware');\nconst http = require('http');\n\n// Create a simple target server for the proxy to forward requests to\nconst targetServer = http.createServer((req, res) => {\n  res.writeHead(200, { 'Content-Type': 'text/plain' });\n  res.end(`Hello from target server! Path: ${req.url}\\n`);\n});\n\ntargetServer.listen(9000, () => {\n  console.log('Target server listening on http://localhost:9000');\n\n  const app = connect();\n\n  // Configure the proxy route: requests to /api will go to http://localhost:9000/target-prefix\n  const proxyOptions = url.parse('http://localhost:9000/target-prefix');\n  app.use('/api', proxy(proxyOptions));\n\n  // Add a simple route to the main app to show it's working\n  app.use('/', (req, res) => {\n    res.writeHead(200, { 'Content-Type': 'text/plain' });\n    res.end('Main app. Try /api/hello to see the proxy in action.\\n');\n  });\n\n  const port = 3000;\n  http.createServer(app).listen(port, () => {\n    console.log(`Connect server running on http://localhost:${port}`);\n    console.log('Test with:');\n    console.log(`  curl http://localhost:${port}/`);\n    console.log(`  curl http://localhost:${port}/api/some/path`);\n    console.log(`Expected output for /api/some/path: \"Hello from target server! Path: /target-prefix/some/path\"`);\n  });\n});","lang":"javascript","description":"Demonstrates setting up a Connect server with `proxy-middleware` to forward requests from `/api` to a local target server running on port 9000."},"warnings":[{"fix":"Migrate to actively maintained proxy solutions such as `http-proxy-middleware` for Express/Connect or `node-http-proxy` for lower-level control, which support modern Node.js and frameworks.","message":"This package is effectively abandoned and has not been updated since 2016. It is built for older versions of Connect and Node.js and is not compatible with modern web frameworks or current Node.js versions (e.g., Express 4+, Node.js >=10).","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Replace with a currently maintained and regularly updated proxy library. Regularly audit your dependencies for security vulnerabilities.","message":"As an abandoned package, `proxy-middleware` does not receive security updates. Using it in production environments is a significant security risk, potentially exposing applications to known vulnerabilities in Node.js core, HTTP/HTTPS modules, or its dependency chain.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"In modern Node.js, `new URL()` is the recommended alternative for URL parsing. However, direct replacement within this package's API is not straightforward; migration to a modern proxy library is the best long-term solution.","message":"The `url.parse()` method, used extensively in the examples, is deprecated in recent Node.js versions. While still functional, it signals an outdated API approach which may lead to issues or removal in future Node.js releases.","severity":"gotcha","affected_versions":">=0.15.0"},{"fix":"Must be used with `require()` in a CommonJS module. For projects using ES Modules, it is highly recommended to use a modern, ESM-compatible proxy middleware instead.","message":"This package is CommonJS-only and does not provide native ES Module support. Attempting to `import` it in an ESM context will result in runtime errors like `ReferenceError: require is not defined`.","severity":"breaking","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Ensure you are using `connect` for your application and correctly initializing it, e.g., `const connect = require('connect'); const app = connect();`. If using Express, you should use an Express-compatible proxy middleware like `http-proxy-middleware`.","cause":"The `app` object is not a Connect application instance or is an incompatible framework (e.g., a vanilla Express app without Connect compatibility shims).","error":"TypeError: app.use is not a function"},{"fix":"This package is CommonJS-only. If your project is ESM, you need to either use a modern, ESM-compatible proxy middleware or configure your build system/Node.js environment to treat the file as CommonJS.","cause":"Attempting to use `require()` in a JavaScript file that is being treated as an ES Module (e.g., within a project with `\"type\": \"module\"` in `package.json`).","error":"ReferenceError: require is not defined"},{"fix":"Carefully check the `url.parse()` options, ensuring the `protocol`, `hostname`, and `pathname` are correctly specified for your target. Also, verify that the middleware's mount path in `app.use('/api', proxy(...))` matches the intended proxy route prefix for incoming requests.","cause":"Incorrect configuration of the `url.parse()` options or the `route` property, leading to the proxy targeting the wrong host/path or not activating for the desired incoming requests.","error":"Requests not being proxied, or incorrect target URL/path."}],"ecosystem":"npm"}