Fix redirect loop: tambah guard lebih ketat di semua file, hapus redirect di .htaccess public
This commit is contained in:
@@ -41,9 +41,14 @@ async function apiRequest(path, options = {}) {
|
||||
localStorage.removeItem('token');
|
||||
localStorage.removeItem('user');
|
||||
// Cek apakah sudah di login page untuk menghindari redirect loop
|
||||
const currentPath = window.location.pathname;
|
||||
const isLoginPage = currentPath.includes('index.php') || currentPath === '/' || currentPath.endsWith('/');
|
||||
if (!isLoginPage) {
|
||||
const currentPath = window.location.pathname.toLowerCase();
|
||||
const isLoginPage = currentPath.includes('index.php') ||
|
||||
currentPath === '/' ||
|
||||
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';
|
||||
}
|
||||
throw new Error('Unauthorized');
|
||||
|
||||
Reference in New Issue
Block a user