Fix admin panel authentication and navigation for static export

- Replace router.push with window.location.href for reliable redirects
- Fix auth check to wait for component mount before accessing localStorage
- Ensure proper redirect after successful login
- Fix redirect behavior on all admin pages (dashboard, colors, requests)
This commit is contained in:
DaX
2025-10-31 02:45:47 +01:00
parent c0ca1e4bb3
commit d3e001707b
4 changed files with 16 additions and 10 deletions

View File

@@ -123,13 +123,16 @@ export default function AdminDashboard() {
// Check authentication
useEffect(() => {
// Wait for component to mount to avoid SSR issues with localStorage
if (!mounted) return;
const token = localStorage.getItem('authToken');
const expiry = localStorage.getItem('tokenExpiry');
if (!token || !expiry || Date.now() > parseInt(expiry)) {
router.push('/upadaj');
window.location.href = '/upadaj';
}
}, [router]);
}, [mounted]);
// Fetch filaments
const fetchFilaments = async () => {