Skip to content

hpoenixf/koa2-proxies

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

koa2 proxies

npm GitHub issues GitHub license Powered by request 基于request的用于koa2的代理中间件 npm install koa2-proxies

example

const koa = require('koa2')

const app = new koa()
const proxy = require('koa2-proxies')
const proxyUrl = ['/v2']
app.use(async function  (ctx, next) {
  console.log(ctx.path)
  if (proxyUrl.some(i => ctx.path.indexOf(i) === 0)) {
    await proxy({host: 'http://api.douban.com', ctx})
  } else {
    await next()
  }
})

const port = 4567
app.listen(port, () => console.log(`==> Listening at http://localhost:${port}`))

then visit http://127.0.0.1:4567/v2/movie/subject/26865690

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published