fix: prevent full page reload on login failure (401 on /auth/login)
The axios 401 interceptor was redirecting to /login for every 401 response, including failed login attempts. Now it skips the redirect when the request is to /auth/login, letting the LoginView handle the error gracefully. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -28,6 +28,9 @@ instance.interceptors.response.use(
|
||||
message = data?.detail || '请求参数有误,请检查一下~'
|
||||
break
|
||||
case 401:
|
||||
if (error.config?.url?.includes('/auth/login')) {
|
||||
break
|
||||
}
|
||||
message = '登录状态已失效~'
|
||||
window.location.href = '/login'
|
||||
return Promise.reject(error)
|
||||
|
||||
Reference in New Issue
Block a user