Maison > Questions et réponses > le corps du texte
gulp配置时使用http-proxy-middleware做代理,有人知道怎么配置多重代理吗?
gulp.task('server', function() {
connect.server({
livereload: true,
root: "./output",
port: 8080,
middleware: function(connect, opt) {
return [
proxy('/test',{
target: 'http://localhost:8000',
changeOrigin: true,
})
]
}
});
});
巴扎黑2017-04-17 15:05:07
return 不是返回数组吗,你试试多写几个proxy
gulp.task('server', function() {
connect.server({
livereload: true,
root: "./output",
port: 8080,
middleware: function(connect, opt) {
return [
proxy('/test',{
target: 'http://localhost:8000',
changeOrigin: true,
}),
proxy('/other-test',{
target: 'http://localhost:9000',
changeOrigin: true,
})
]
}
});
});
官方给的例子:
https://github.com/chimurai/h...
PHP中文网2017-04-17 15:05:07
@hjzheng 一样,不过把proxy 单独出来写了
var proxy1 = proxyMiddleware('/api', {
target: 'http://huggies.kmapp.net',
changeOrigin: true,
pathRewrite: {
'^/api' : '/campaign_huggies/t3store_freeuse' // rewrite paths
},
});
然后 middleware: [proxy1, proxy2] 这样配置