Fix redirect loop: hapus auto-redirect di index.php, hanya redirect setelah login berhasil
This commit is contained in:
@@ -40,10 +40,9 @@ async function apiRequest(path, options = {}) {
|
||||
// Unauthorized → clear token & redirect to login
|
||||
localStorage.removeItem('token');
|
||||
localStorage.removeItem('user');
|
||||
sessionStorage.removeItem('auth_redirect_done');
|
||||
// Cek apakah sudah di login page untuk menghindari redirect loop
|
||||
const currentPath = window.location.pathname;
|
||||
const isLoginPage = currentPath.includes('index.php');
|
||||
const isLoginPage = currentPath.includes('index.php') || currentPath === '/' || currentPath.endsWith('/');
|
||||
if (!isLoginPage) {
|
||||
window.location.href = '../index.php';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user