xiangwenbin / koa-proxies

a koa@2.x proxy middleware

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Koa Proxies

NPM Build Status

Koa@2.x/next middlware for http proxy

Powered by http-proxy.

Installation

$ npm install koa-proxies --save

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
}))

JavaScript Style Guide

About

a koa@2.x proxy middleware

License:MIT License


Languages

Language:JavaScript 100.0%