如果我正确理解您的问题,那么解决方案应该是使用
pathRewrite
基于每个代理的参数。
例如,如果你的应用程序在
/fpHandling/api/*
那你就要把请求转送到相当于
http://localhost:9999/*
.
要实现这一点,您可以像这样更新选项配置:
var options = {
contentBase: "src/client",
proxy: {
"/fpHandling/api/*": {
target: "http://localhost:9999",
secure: false,
pathRewrite: { '^/fpHandling/api': '' }
},
"/fpHandling/spark/*": {
target: "http://localhost:9999",
secure: false,
pathRewrite: { '^/fpHandling/spark': '' }
},
"/fpCase/api/*": {
target: "http://localhost:8888",
secure: false,
pathRewrite: { '^/fpCase/api': '' }
}
},
publicPath: config.output.publicPath,
hot: true,
noInfo: true,
historyApiFallback: false,
stats: {
colors: true,
},
};
希望这有帮助!