popomore / koa-proxy

Proxy middleware for koa
223 stars 102 forks source link

如何为站点某个目录做代理,另:koa里没有app.get呀 #42

Closed windbell2 closed 7 years ago

windbell2 commented 8 years ago

我想实现http://localhost:3000/proxy => http://10.2.xx.xx/ 这要什么弄 另: readme的例子, ` var koa = require('koa'); var proxy = require('koa-proxy'); var app = koa(); app.use(proxy({ host: 'http://alicdn.com' })); app.listen(3000);

app.get('index.js', proxy({ url: 'http://alicdn.com/index.js' })); app.get('index.js', proxy({ host: 'http://alicdn.com', map: { 'index.js': 'index-1.js' } })); ` app.get 这样对吗,koa也没有这个方法呀。。。why

popomore commented 7 years ago

app.get 是 koa-router 提供的

上面的问题可以用 koa-mount,也可以前面加个中间件,把 pathname 去掉 proxy 路径。