{"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`.","language":"javascript","status":"abandoned","last_verified":"Tue Apr 21","install":{"commands":["npm install proxy-middleware"],"cli":null},"imports":["const proxy = require('proxy-middleware');","const proxy = require('proxy-middleware');\n// ... then use proxy(options)"],"auth":{"required":false,"env_vars":[]},"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}