Fix jwt-token

This commit is contained in:
2025-08-19 03:40:47 +02:00
parent 7b31d7f5e5
commit c042eed0e9
2 changed files with 13 additions and 5 deletions

View File

@@ -46,12 +46,10 @@ api.interceptors.response.use(
(response) => response,
(error) => {
if (error.response?.status === 401) {
// Token expired or invalid - let AuthContext handle this
// Token expired or invalid - remove token and let ProtectedRoute handle navigation
localStorage.removeItem('token');
// Only redirect if not already on login page
if (window.location.pathname !== '/login') {
window.location.href = '/login';
}
// Force a state update by dispatching a custom event
window.dispatchEvent(new CustomEvent('auth-logout'));
}
return Promise.reject(error);
}