Ganti index.php menjadi index.html untuk menghindari redirect loop PHP
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ export const Auth = {
|
||||
localStorage.removeItem(TOKEN_KEY);
|
||||
localStorage.removeItem(USER_KEY);
|
||||
sessionStorage.removeItem('auth_redirect_done');
|
||||
window.location.href = '../index.php';
|
||||
window.location.href = '../index.html';
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -697,8 +697,10 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
if (!Auth.isAuthenticated()) {
|
||||
// Cek apakah sudah di login page untuk mencegah 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 === '';
|
||||
@@ -706,7 +708,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
// JANGAN redirect jika sudah di login page atau root
|
||||
if (!isLoginPage && currentPath.includes('dashboard')) {
|
||||
// Hanya redirect jika benar-benar di halaman dashboard
|
||||
window.location.href = '../index.php';
|
||||
window.location.href = '../index.html';
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user