fix(auth): 401拦截器排除auth端点 + login默认跳转/app/dashboard #1228
Reference in New Issue
Block a user
Delete Branch "fix/1221-auth-401-interceptor-v2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
修复内容
1.
client.ts— 401 拦截器排除 auth 端点/auth/login返回 401(密码错误)时,拦截器错误执行clearAuth()+window.location.href = "/"硬跳转isAuthEndpoint判断,排除/auth/login、/auth/register、/auth/forgot-password、/auth/reset-password2.
useAuth.ts— login 默认跳转路径login()默认跳转/,与Login.tsx的navigate("/app/dashboard")不一致/app/dashboard3.
scripts/ci/vitest_incremental.sh— ANSI 转义码修复sed去除 ANSI 转义码CI 状态
关联
3e24f8de【阻塞级判定】
📊 审查概览
🔴 阻塞级问题(必须修复)
无
💡 改进建议(不阻塞合并)
无
✅ 良好实践
[apps/web/src/api/client.ts] 精准的 401 处理逻辑
isAuthEndpoint判断,有效避免了在登录、注册等接口返回 401(如密码错误)时错误地触发全局 Token 刷新逻辑。这解决了常见的认证死循环或错误提示异常问题,逻辑严谨。[scripts/ci/vitest_incremental.sh] 提升 CI 脚本健壮性
sed处理去除 ANSI 转义码,防止终端颜色代码干扰文本匹配。这是一个很好的工程实践,确保了 CI 环境在不同配置下的稳定性。🤖 由 AI 代码审查机器人自动生成 | 2026-08-03 06:33:40 | 模型:
🚀 预览环境已部署
CI全绿,自动审批通过。
CI全绿,自动审批通过。
🗑️ 预览环境已清理
PR #1228 已关闭或合并,对应的预览环境已被清理。