From 3189873e5494d8134d38f5c14c6dc38267da79b1 Mon Sep 17 00:00:00 2001 From: liulong <18539103286> Date: Sun, 7 Jun 2026 13:48:22 +0800 Subject: [PATCH] fix(dev-server): proxy /auth to txw-cloud gateway MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 阶段 1 收尾 BUG-C:auth-refactor.js 调 /auth/loginByPassword (txw-cloud 新栈),vue.config.js 的 devServer.proxy 缺 ^/auth 条目, dev server 不知把请求转给 8080 gateway,请求落到 SPA fallback 返回 index.html,登录永远走不通。 target 指向 http://localhost:8080(与 .env.development.new 中 VUE_APP_MHZC_PROXY 一致,8080 是新 gateway,auth 9200 / system 9201 都在它后面)。 不破坏 9002 老栈:^/sso / ^/mhzc / ^/gxzx / ^/yygl 保持原状。 验收:点登录按钮 → localStorage 自动出现 txw_access_token → /system/user/getInfo 请求头带 Authorization: Bearer ... --- txw-mhzc-web/vue.config.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/txw-mhzc-web/vue.config.js b/txw-mhzc-web/vue.config.js index 42cc310..580dd58 100644 --- a/txw-mhzc-web/vue.config.js +++ b/txw-mhzc-web/vue.config.js @@ -288,6 +288,12 @@ module.exports = { // Vue CLI prepareProxy 用 pathname.match(代理键) 判断;键写 '/mhzc' 会变成匹配路径里任意位置的 /mhzc, // 会误伤 SPA 路由 /view/mhzc/...,刷新时整页请求被转发到后端导致 Proxy error。必须用 ^ 限定为路径前缀。 proxy: { + // 阶段 1 收尾 BUG-C:auth-refactor.js 调 /auth/loginByPassword(txw-cloud 新栈)。 + // 8080 是新 gateway(auth 9200 / system 9201 都在它后面),不配这条会落到 SPA fallback。 + '^/auth': { + target: 'http://localhost:8080', + changeOrigin: true, + }, '^/sso': { // target: 'http://localhost:9300', // target: 'http://carbon.liantu.tech',