@erwinv/koa-http-proxy
v1.1.2
Published
Koa HTTP proxy middleware powered by http-party/node-http-proxy.
Downloads
2
Maintainers
Readme
koa-http-proxy
Koa HTTP proxy middleware powered by http-party/node-http-proxy.
Installation
npm install --save @erwinv/koa-http-proxy
Usage
import { KoaHttpProxy } from '@erwinv/koa-http-proxy'
import { default as Koa, Middleware } from 'koa'
new Koa()
.use(KoaHttpProxy(process.env.PROXY_TARGET, {
xfwd: true,
changeOrigin: true,
followRedirects: true,
proxyTimeout: 60 * 1000,
}))
.listen(process.env.PORT)
Options
Inherited from third-party dependency
These options are the same as those of http-party/node-http-proxy with the following exceptions:
target
: same type but is moved outside of the options object and should be passed as first argument to the middleware factory function insteadws
: WebSockets not supportedselfHandleResponse
: not supported (middleware internals depends on this being always false)
Own
bufferResponseBody
: boolean, default: false - if true, the proxied response will be buffered in full before sending it to client (useful for proxies that need to modify/decorate the JSON response body for example). Otherwise (if false), the proxied response is streamed directly to the client. Note: the buffered response body is aBuffer
and may need to be decompressed (depending onContent-Encoding
), stringified, and/or parsed (depending onContent-Type
) before it can be read or modified.