koa-better-proxies
v0.0.3
Published
Http Proxy Middleware for [email protected]/next, change by koa-proxies
Downloads
7
Readme
Koa Proxies
[email protected]/next middlware for http proxy
Powered by http-proxy
.
Installation
$ npm install koa-proxies --save
Options
http-proxy events
options.events = {
error (err, req, res) { },
proxyReq (proxyReq, req, res) { },
proxyRes (proxyRes, req, res) { }
}
Usage
// dependencies
const Koa = require('koa')
const proxy = require('koa-proxies')
const httpsProxyAgent = require('https-proxy-agent')
const app = new Koa()
// middleware
app.use(proxy('/octocat', {
target: 'https://api.github.com/users',
changeOrigin: true,
agent: new httpsProxyAgent('http://1.2.3.4:88'),
rewrite: path => path.replace(/^\/octocat(\/|\/\w+)?$/, '/vagusx'),
logs: true
}))