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 doesn’t return an array, try writing more proxies
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,
})
]
}
});
});
Official example:
https://github.com/chimurai/h...
PHP中文网2017-04-17 15:05:07
@hjzheng It’s the same, but the proxy is written separately
var proxy1 = proxyMiddleware('/api', {
target: 'http://huggies.kmapp.net',
changeOrigin: true,
pathRewrite: {
'^/api' : '/campaign_huggies/t3store_freeuse' // rewrite paths
},
});
Then configure middleware: [proxy1, proxy2] like this