39 lines
1.6 KiB
TypeScript
39 lines
1.6 KiB
TypeScript
/**
|
||
* 冒烟/视觉验收专用 vite 配置(用完即删,勿提交):
|
||
* - 端口 8083(独立于 dev 8081)
|
||
* - 代理 /api → 本地后端 8107,路径改写 /api → /manage(绕过 CAS 过滤器 url-pattern /api/*),
|
||
* 并给每个请求注入 currentrole={userId,schId} 模拟登录态(后端 ControllerUserContextAspect 兜底解析)。
|
||
* - 登录身份可用环境变量切换:SMOKE_UID(默认 10001 王建军)/ SMOKE_SCH(默认 3)
|
||
*/
|
||
import base from "./vite.config";
|
||
|
||
const SMOKE_UID = Number(process.env.SMOKE_UID || 10001);
|
||
const SMOKE_SCH = Number(process.env.SMOKE_SCH || 3);
|
||
|
||
export default (async () => {
|
||
const cfg = await (typeof base === "function" ? base({ command: "serve", mode: "development" }) : base);
|
||
const c = cfg as any;
|
||
c.server = {
|
||
...c.server,
|
||
port: 8083,
|
||
proxy: {
|
||
"/api": {
|
||
target: "http://localhost:8107",
|
||
changeOrigin: true,
|
||
rewrite: (p: string) => p.replace(/^\/api/, "/manage"),
|
||
configure: (proxy: any) => {
|
||
proxy.on("proxyReq", (proxyReq: any) => {
|
||
try {
|
||
// 后端切面对 header currentrole 会做 URLDecoder.decode,故传编码串
|
||
proxyReq.setHeader("currentrole", encodeURIComponent(JSON.stringify({ userId: SMOKE_UID, schId: SMOKE_SCH })));
|
||
} catch {
|
||
/* 注入失败保持原样 */
|
||
}
|
||
});
|
||
},
|
||
},
|
||
},
|
||
};
|
||
return c;
|
||
})();
|