A middleware for Koa that configures http2-proxy to reverse-proxy HTTP/HTTPS/WebSocket requests with minimal setup. Version 0.0.4 (latest) provides context matching via path strings or glob patterns, path rewriting, virtual host routing, and WebSocket support. It is a fork of http-proxy-middleware adapted for Koa's async middleware pattern and HTTP/2. Lightweight alternative to koa-proxies or koa-proxy, with similar API to http-proxy-middleware but natively async. Release cadence is low; no updates since 2022.
npm install koa-http2-proxyVerified import paths — ran on the pinned version, not inferred.
Creates a Koa app that proxies all requests to httpbin.org with changeOrigin true for virtual hosting.
Use CommonJS require() or configure your bundler to handle CJS dependencies.
Create a declaration file (e.g., koa-http2-proxy.d.ts) or use @ts-ignore.
Implement a custom upgrade handler using the proxy.ws method: server.on('upgrade', proxy.upgrade).Run `npm install koa-http2-proxy` and ensure require path is correct.
Change from `import proxy from 'koa-http2-proxy'` to `const proxy = require('koa-http2-proxy')`.Use a different port or kill the process using port 3000: `kill $(lsof -t -i:3000)`.