From 7d7f652e9333ae3e31e0ee83e34ac409885c2d15 Mon Sep 17 00:00:00 2001 From: smail Date: Sun, 30 Aug 2026 20:10:40 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9A=94=E7=A6=BB=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E7=9A=84=E8=AE=A4=E8=AF=81=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fe/src/utils/axios.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/fe/src/utils/axios.js b/fe/src/utils/axios.js index c7eed91..00c2b5f 100644 --- a/fe/src/utils/axios.js +++ b/fe/src/utils/axios.js @@ -46,13 +46,19 @@ function attachApiErrorDetails(error) { } function isSetupRequest(config) { - const url = String(config?.url || '').split('?')[0] - return url === '/api/setup' || url === '/api/v1/setup' + const rawUrl = String(config?.url || '').split('?')[0] + let path = rawUrl + try { + path = new URL(rawUrl, config?.baseURL || window.location.origin).pathname + } catch (error) { + path = rawUrl + } + return path === '/api/setup' || path === '/api/v1/setup' } http.interceptors.response.use(async (response) => { //响应成功 - if (response.data.errorNo === 403 && !isSetupRequest(response.config)) { + if (response.data?.errorNo === 403 && !isSetupRequest(response.config)) { await router.replace({ path: '/login', @@ -62,7 +68,7 @@ http.interceptors.response.use(async (response) => { }); } //响应成功 - if (response.data.errorNo === 402) { + if (response.data?.errorNo === 402 && !isSetupRequest(response.config)) { await router.replace({ path: '/setup', query: {