diff --git a/client/src/pages/MapView.jsx b/client/src/pages/MapView.jsx index 66da243..a6d2f87 100644 --- a/client/src/pages/MapView.jsx +++ b/client/src/pages/MapView.jsx @@ -195,10 +195,9 @@ const MapView = () => { [maxLat + latPadding, maxLon + lonPadding] // Northeast ]; - setMapBounds(bounds); - - // Only set center on initial load, not on periodic refreshes + // Only set bounds and center on initial load, not on periodic refreshes if (isInitialLoad) { + setMapBounds(bounds); const centerLat = (minLat + maxLat) / 2; const centerLon = (minLon + maxLon) / 2; setMapCenter([centerLat, centerLon]); diff --git a/client/src/services/api.js b/client/src/services/api.js index 6751b7d..2b5e835 100644 --- a/client/src/services/api.js +++ b/client/src/services/api.js @@ -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); }