fix(auth): 401拦截器排除auth端点 + login默认跳转/app/dashboard (#1228)
CI/CD Pipeline / Validate - Type Check (mypy) (push) Successful in 1m7s
CI/CD Pipeline / Validate - Migration (alembic) (push) Successful in 1m8s
CI/CD Pipeline / Frontend Unit Tests (push) Failing after 2m22s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 3m1s
CI/CD Pipeline / Build Staging Web Image (push) Successful in 5m15s
CI/CD Pipeline / Validate - Code Quality (push) Successful in 6m2s
CI/CD Pipeline / Integration Tests (push) Successful in 2m6s
CI/CD Pipeline / Unit Tests (push) Successful in 10m29s
CI/CD Pipeline / Build Staging API Image (push) Successful in 12m41s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 40s
CI/CD Pipeline / Staging API Integration Tests (push) Failing after 18s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 32s
CI/CD Pipeline / Staging E2E Tests (push) Failing after 53s
CI/CD Pipeline / Canary Release to Production (push) Failing after 1056h27m41s
CI/CD Pipeline / Build Production Worker Image (push) Failing after 1056h30m52s
CI/CD Pipeline / Production Browser E2E (push) Failing after 1056h30m51s
CI/CD Pipeline / Build Production Web Image (push) Failing after 1056h30m52s
CI/CD Pipeline / Deploy Production (push) Failing after 1056h30m51s
CI/CD Pipeline / PR Build Web Image (push) Failing after 1056h41m20s
CI/CD Pipeline / Build Production API Image (push) Failing after 1056h30m52s
CI/CD Pipeline / PR Build API Image (push) Failing after 1056h41m22s
CI/CD Pipeline / Check if frontend-only change (push) Failing after 1056h41m24s
CI/CD Pipeline / CI Gate (push) Failing after 1057h4m6s
CI/CD Pipeline / PR Build Worker Image (push) Failing after 1057h14m35s
CI/CD Pipeline / Frontend Lint (push) Failing after 1057h14m37s

Co-authored-by: xiaoxia <dev@xiaoxiajianji.com>
Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
This commit was merged in pull request #1228.
This commit is contained in:
2026-08-03 14:46:00 +08:00
committed by auto-approve-bot
parent 3e24f8de4a
commit 52ab7a91e0
3 changed files with 20 additions and 4 deletions
+15 -1
View File
@@ -57,7 +57,21 @@ apiClient.interceptors.response.use(
}
// 401 → 尝试刷新 Token
if (error.response?.status === 401 && originalRequest && !originalRequest._retry) {
// 排除 auth 端点:登录/注册/找回密码的 401 是正常业务响应(如密码错误),
// 不应触发 token 刷新或登出跳转,走后面的错误提示逻辑即可
const requestUrl = originalRequest?.url || ""
const isAuthEndpoint =
requestUrl.includes("/auth/login") ||
requestUrl.includes("/auth/register") ||
requestUrl.includes("/auth/forgot-password") ||
requestUrl.includes("/auth/reset-password")
if (
error.response?.status === 401 &&
originalRequest &&
!originalRequest._retry &&
!isAuthEndpoint
) {
const refreshToken = useAuthStore.getState().refreshToken
// 无 refresh_token → 直接登出