{"library":"middleware-proxy","title":"Connect/Express HTTP Proxy Middleware","description":"middleware-proxy is a connect-compliant HTTP middleware designed for transparently redirecting incoming requests, primarily useful in development environments where a frontend served by Node.js needs to proxy API calls to a separate backend server. It simplifies integrated project development by allowing developers to access static assets through a local Node server while redirecting RESTful API calls to an external backend. The current stable version is 2.0.5, with recent releases focusing on bug fixes like handling HTTPS and URL parsing edge cases. The package provides a flexible API that supports regular expressions for URL matching and offers an optional feature to strip URL prefixes before forwarding requests, making it suitable for managing API gateway differences between development and production setups.","language":"javascript","status":"maintenance","last_verified":"Thu Apr 23","install":{"commands":["npm install middleware-proxy"],"cli":null},"imports":["const proxy = require('middleware-proxy');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const express = require('express');\nconst app = express();\nconst http = require('http');\nconst proxy = require('middleware-proxy');\n\n// Basic Express setup\napp.set('port', process.env.PORT || 3000);\napp.use(express.static(__dirname + '/app')); // Serve static files from './app'\n\n// Proxy requests starting with '/service' to http://localhost:8080\napp.use(proxy('/service', 'http://localhost:8080'));\n\nhttp.createServer(app).listen(app.get('port'), function() {\n    console.log(`Express server listening on port ${app.get('port')}`);\n});\n","lang":"javascript","description":"Demonstrates how to integrate middleware-proxy with an Express application to redirect requests starting with '/service' to a backend server.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}