Closed windbell2 closed 7 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
app.get 是 koa-router 提供的
上面的问题可以用 koa-mount,也可以前面加个中间件,把 pathname 去掉 proxy 路径。
我想实现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