From 275a7c83af01df0a3b2d0588f558950cd7aeef60 Mon Sep 17 00:00:00 2001 From: lijing Date: Tue, 13 Oct 2026 16:36:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(dev):=20=E6=9C=AC=E5=9C=B0=E8=A1=A5?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E5=89=8D=E7=BC=80=E4=BB=A3=E7=90=86=EF=BC=8C?= =?UTF-8?q?=E8=AE=A9=E3=80=8C=E8=B7=AF=E5=BE=84=E6=8B=BC=E9=94=99=E3=80=8D?= =?UTF-8?q?=E5=9C=A8=E6=9C=AC=E5=9C=B0=E5=B0=B1=E6=9A=B4=E9=9C=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 请假的模块 key 是 homeleave、真实路由前缀是 /home-leave,后端下发的 optionCall 与附件 uploadPath 都带真实前缀。本地只代理 /api 时,这些带前缀 的请求会直接 404 —— 于是「后端把模块前缀拼错」这类问题在本地测不出来, 请假佐证材料上传 404 就是这么漏到线上的。 这里把各模块前缀一并代理到本地 mock,让本地环境与线上同形。 --- vite.config.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/vite.config.ts b/vite.config.ts index 9a40d8e..6dc6bad 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -92,6 +92,15 @@ export default defineConfig((): UserConfig => { target: "http://localhost:8093", changeOrigin: true, }, + // 业务模块前缀:模块的**路由前缀与模块 key 不一定同名** —— 请假的 key 是 + // `homeleave` 而真实前缀是 `/home-leave`。后端下发的 optionCall / 附件 uploadPath + // 都会带上真实前缀,本地一并代理到 mock,好让「路径拼错」这类问题在本地就暴露 + // (请假的佐证材料就曾因为拼成 /homeleave/api/base/FileUpload 而 404,直到上线才发现)。 + "/home-leave": { target: "http://localhost:8093", changeOrigin: true }, + "/campusnotice": { target: "http://localhost:8093", changeOrigin: true }, + "/dormnotice": { target: "http://localhost:8093", changeOrigin: true }, + "/familyactivity": { target: "http://localhost:8093", changeOrigin: true }, + "/coursehomework": { target: "http://localhost:8093", changeOrigin: true }, }, }, base: "./",