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;