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.
npm install middleware-proxyVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to integrate middleware-proxy with an Express application to redirect requests starting with '/service' to a backend server.
Update usage from `app.use(function() { return proxy(...) })` to `app.use(proxy(...))` directly.Run `npm install middleware-proxy` or `yarn add middleware-proxy`.
Ensure you are using `const proxy = require('middleware-proxy');` for CommonJS. If upgrading from `<v2.0.1`, ensure you are now using `app.use(proxy(...))` directly without an outer function wrapper.Double-check the 'matcher' argument to ensure it correctly identifies the desired URLs (e.g., `/api/v1` for `http://localhost:8080/api/v1`). Verify the 'server' URL is accurate and accessible. Ensure 'path_to_strip' correctly removes the desired prefix without altering the base path incorrectly (e.g., stripping `/api` from `/api/posts` to become `/posts`).
No dependency data recorded yet.