Fix jwt-token

This commit is contained in:
2025-09-19 07:18:52 +02:00
parent 7626df36b6
commit 547b29af78
5 changed files with 523 additions and 15 deletions

View File

@@ -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)
}