Ganti index.php menjadi index.html untuk menghindari redirect loop PHP

This commit is contained in:
mwpn
2025-12-18 13:36:36 +07:00
parent 6b1de8830d
commit c4d4d65882
8 changed files with 22 additions and 12 deletions

View File

@@ -42,14 +42,16 @@ async function apiRequest(path, options = {}) {
localStorage.removeItem('user');
// Cek apakah sudah di login page untuk menghindari redirect loop
const currentPath = window.location.pathname.toLowerCase();
const isLoginPage = currentPath.includes('index.php') ||
const isLoginPage = currentPath.includes('index.html') ||
currentPath.includes('index.php') ||
currentPath === '/' ||
currentPath === '/index.html' ||
currentPath === '/index.php' ||
currentPath.endsWith('/') ||
currentPath === '';
// Hanya redirect jika benar-benar di halaman dashboard, bukan di login page
if (!isLoginPage && currentPath.includes('dashboard')) {
window.location.href = '../index.php';
window.location.href = '../index.html';
}
throw new Error('Unauthorized');
}