隔离初始化接口的认证跳转
Some checks are pending
Security Checks / security (push) Waiting to run

This commit is contained in:
smail 2026-08-30 20:10:40 +08:00
parent 00a87948c2
commit 7d7f652e93

View File

@ -46,13 +46,19 @@ function attachApiErrorDetails(error) {
} }
function isSetupRequest(config) { function isSetupRequest(config) {
const url = String(config?.url || '').split('?')[0] const rawUrl = String(config?.url || '').split('?')[0]
return url === '/api/setup' || url === '/api/v1/setup' 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) => { 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({ await router.replace({
path: '/login', 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({ await router.replace({
path: '/setup', path: '/setup',
query: { query: {