{"id":18475,"library":"koa-http2-proxy","title":"koa-http2-proxy","description":"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.","status":"active","version":"0.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/ontola/koa-http2-proxy","tags":["javascript","reverse","proxy","middleware","http","https","koa","browser-sync","websocket"],"install":[{"cmd":"npm install koa-http2-proxy","lang":"bash","label":"npm"},{"cmd":"yarn add koa-http2-proxy","lang":"bash","label":"yarn"},{"cmd":"pnpm add koa-http2-proxy","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core proxy functionality; wraps http2-proxy for HTTP/2 support","package":"http2-proxy","optional":false},{"reason":"Context path matching with glob patterns","package":"micromatch","optional":true}],"imports":[{"note":"This package does not ship ESM; use CommonJS require. There is no default ES import.","wrong":"import proxy from 'koa-http2-proxy';","symbol":"default","correct":"const proxy = require('koa-http2-proxy');"},{"note":"The module exports a single function as default; named destructuring fails.","wrong":"const { proxy } = require('koa-http2-proxy');","symbol":"proxy function","correct":"import proxy from 'koa-http2-proxy'; // use with bundler that supports CJS interop"},{"note":"No TypeScript declarations included; use @ts-ignore or create custom .d.ts.","wrong":"import proxy from 'koa-http2-proxy'; // types missing","symbol":"TypeScript types","correct":"// @ts-ignore\nimport proxy from 'koa-http2-proxy';"}],"quickstart":{"code":"const Koa = require('koa');\nconst proxy = require('koa-http2-proxy');\nconst app = new Koa();\n\napp.use(proxy({ target: 'http://httpbin.org', changeOrigin: true }));\n\napp.listen(3000, () => {\n  console.log('Proxy server running on http://localhost:3000');\n  console.log('Try: curl http://localhost:3000/ip => httpbin.org/ip');\n});","lang":"javascript","description":"Creates a Koa app that proxies all requests to httpbin.org with changeOrigin true for virtual hosting."},"warnings":[{"fix":"Use CommonJS require() or configure your bundler to handle CJS dependencies.","message":"The package does not support ES modules (ESM). require() is the only import method.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Create a declaration file (e.g., koa-http2-proxy.d.ts) or use @ts-ignore.","message":"No TypeScript type definitions included; TypeScript users will need to define their own types or use @ts-ignore.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Implement a custom upgrade handler using the proxy.ws method: server.on('upgrade', proxy.upgrade).","message":"WebSocket proxying requires manual upgrade handling via server.on('upgrade') because Koa does not handle WebSocket upgrades automatically.","severity":"gotcha","affected_versions":">=0.0.1"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install koa-http2-proxy` and ensure require path is correct.","cause":"Package not installed or path incorrect.","error":"Error: Cannot find module 'koa-http2-proxy'"},{"fix":"Change from `import proxy from 'koa-http2-proxy'` to `const proxy = require('koa-http2-proxy')`.","cause":"Using ES import syntax (import) instead of require.","error":"TypeError: proxy is not a function"},{"fix":"Use a different port or kill the process using port 3000: `kill $(lsof -t -i:3000)`.","cause":"Port 3000 already in use.","error":"Error: listen EADDRINUSE :::3000"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}