Эх сурвалжийг харах

Fix 401 handler: only clear token and reload if token exists

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
k4be 2 долоо хоног өмнө
parent
commit
2edcff8a58

+ 4 - 2
gpx-vis-frontend/js/api.js

@@ -16,8 +16,10 @@ const API = (() => {
 
     const res = await fetch(url, opts);
     if (res.status === 401) {
-      localStorage.removeItem('token');
-      window.location.reload();
+      if (getToken()) {
+        localStorage.removeItem('token');
+        window.location.reload();
+      }
       throw new Error('Unauthorized');
     }