Fix jwt-token
This commit is contained in:
@@ -27,9 +27,17 @@ api.interceptors.response.use(
|
||||
(response) => response,
|
||||
(error) => {
|
||||
if (error.response?.status === 401) {
|
||||
const errorData = error.response.data;
|
||||
console.warn('🔐 Authentication failed:', errorData?.message || 'Unknown error');
|
||||
|
||||
// Clear authentication data
|
||||
localStorage.removeItem('management_token')
|
||||
localStorage.removeItem('management_user')
|
||||
window.location.href = '/login'
|
||||
|
||||
// Check if the backend indicates we should redirect to login
|
||||
if (errorData?.redirectToLogin !== false) {
|
||||
window.location.href = '/login'
|
||||
}
|
||||
}
|
||||
return Promise.reject(error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user