Fix jwt-token

This commit is contained in:
2025-08-19 04:06:54 +02:00
parent 3c91415525
commit 0cb59f1b25
2 changed files with 6 additions and 7 deletions

View File

@@ -49,10 +49,10 @@ api.interceptors.response.use(
(response) => response,
(error) => {
if (error.response?.status === 401) {
console.warn('⚠️ 401 Unauthorized detected for:', error.config?.url);
// Temporarily comment out auto-logout to debug
// localStorage.removeItem('token');
// window.dispatchEvent(new CustomEvent('auth-logout'));
// Token expired or invalid - remove token and let ProtectedRoute handle navigation
localStorage.removeItem('token');
// Force a state update by dispatching a custom event
window.dispatchEvent(new CustomEvent('auth-logout'));
}
return Promise.reject(error);
}