This commit is contained in:
2024-12-20 14:41:32 +08:00
parent 9a9a08b7ca
commit ee1ae711f5
4 changed files with 54 additions and 5 deletions

View File

@@ -29,13 +29,41 @@ export default ({ mode }: ConfigEnv): UserConfigExport => {
"/base": {
target: "http://127.0.0.1:9098",
changeOrigin: true,
rewrite: path => path.replace(/^\/base/, "")
rewrite: path => path.replace(/^\/base/, ""),
configure: (proxy, options) => {
// 添加调试日志
proxy.on("proxyReq", (proxyReq, req, res) => {
console.log(res);
console.log("代理请求:", {
from: req.url,
to: options.target + proxyReq.path
});
});
proxy.on("proxyRes", (proxyRes, req, res) => {
console.log(res);
console.log("代理响应:", {
path: req.url,
status: proxyRes.statusCode
});
});
proxy.on("error", (err, req, res) => {
console.log(res);
console.log(req);
console.error("代理错误:", err);
});
}
},
// 第二个代理后端地址
"/otherApi": {
target: "http://127.0.0.1:3290",
changeOrigin: true,
rewrite: path => path.replace(/^\/otherApi/, "")
},
// 第三个代理后端地址
"/biz": {
target: "http://127.0.0.1:8089",
changeOrigin: true,
rewrite: path => path.replace(/^\/biz/, "")
}
},
// 预热文件以提前转换和缓存结果,降低启动期间的初始页面加载时长并防止转换瀑布