Have opinions about JavaScript? We want to hear them. Take the 2018 JavaScript Ecosystem Survey »

koa-proxies

0.8.1 • Public • Published

Koa Proxies

NPM TavisCI Build CircieCI Build Coverage NPM Downloads Greenkeeper badge

Koa@2.x/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'), // if you need or just delete this line
  rewrite: path => path.replace(/^\/octocat(\/|\/\w+)?$/, '/vagusx'),
  logs: true
}))

JavaScript Style Guide

install

npm i koa-proxies

Downloadsweekly downloads

2,422

version

0.8.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability