From f7f0a89723c94fb74026ee55c5c8175877f5e78a Mon Sep 17 00:00:00 2001 From: Rogee Date: Mon, 2 Feb 2026 20:38:59 +0800 Subject: [PATCH] fix: allow global auth redirect without tenant --- frontend/portal/src/utils/request.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/portal/src/utils/request.js b/frontend/portal/src/utils/request.js index 1fcd49c..c8bf68d 100644 --- a/frontend/portal/src/utils/request.js +++ b/frontend/portal/src/utils/request.js @@ -7,7 +7,8 @@ export async function request(endpoint, options = {}) { const baseUrl = isAuthRequest ? "/v1" : tenantCode ? `/v1/t/${tenantCode}` : "/v1"; if (!tenantCode && !isAuthRequest && !endpoint.startsWith("/tenants")) { - throw new Error("Tenant code missing in URL"); + // 无租户时仍允许访问公共入口,避免全局页面 404 + // 这里改为不抛错,由调用方控制跳转 } const token = localStorage.getItem("token"); @@ -47,7 +48,7 @@ export async function request(endpoint, options = {}) { if (res.status === 401) { localStorage.removeItem("token"); localStorage.removeItem("user"); - const loginPath = tenantCode ? `/t/${tenantCode}/auth/login` : "/auth/login"; + const loginPath = "/auth/login"; // Redirect to login if not already there if (!window.location.pathname.includes("/auth/login")) { window.location.href = loginPath;