fix(auth): enhance error handling for 401 status with specific error codes

This commit is contained in:
sheldon66 2025-03-08 00:38:37 +08:00
parent 61f98aaa33
commit 69575af6a9

View File

@ -61,7 +61,7 @@ export function authCheckMiddleware({ app }: { app: Application }) {
app.apiClient.auth.setToken(newToken); app.apiClient.auth.setToken(newToken);
} }
if (error.status === 401) { if (error.status === 401 && firstError?.code && AuthErrorCode[firstError.code]) {
app.apiClient.auth.setToken(''); app.apiClient.auth.setToken('');
if (pathname === app.getHref('signin') && firstError?.code !== AuthErrorCode.EMPTY_TOKEN && error.config) { if (pathname === app.getHref('signin') && firstError?.code !== AuthErrorCode.EMPTY_TOKEN && error.config) {
error.config.skipNotify = false; error.config.skipNotify = false;