A Koa2 middleware wrapping http-proxy-middleware to proxy requests based on URL patterns using path-to-regexp. Version 0.0.4 is the current stable release; the package is infrequently updated. It provides a declarative way to configure multiple proxy targets in Koa2 applications, leveraging the mature http-proxy-middleware for WebSocket and HTTP proxying. Unlike generic Koa proxy middlewares, it uses path-to-regexp for route matching, allowing dynamic route parameters. It ships TypeScript definitions.
npm install koa2-proxy-middlewareVerified import paths — ran on the pinned version, not inferred.
Creates a Koa server that proxies all requests matching '/api/(.*)' to httpbin.org using the proxy middleware.
Use require() or configure module resolution to allow CommonJS.
Ensure proxy middleware is used before koa-bodyparser or similar body parsers.
No action needed unless you rely on specific regexp behavior.
Ensure patterns follow path-to-regexp syntax (e.g., '/:param', '/(.*)').
Run `npm install koa2-proxy-middleware`.
Use `const proxy = require('koa2-proxy-middleware')`.Install http-proxy-middleware explicitly: `npm install http-proxy-middleware`.