Fix ERR_TOO_MANY_REDIRECTS: hapus public/index.php dan tambah guard untuk prevent redirect loop
This commit is contained in:
@@ -43,6 +43,7 @@ retribusi (frontend)/
|
||||
## Konfigurasi
|
||||
|
||||
File `public/dashboard/js/config.js` mengatur:
|
||||
|
||||
- API Base URL (auto-detect local/production)
|
||||
- API Key untuk autentikasi
|
||||
|
||||
@@ -55,12 +56,14 @@ File `public/dashboard/js/config.js` mengatur:
|
||||
## Production
|
||||
|
||||
Deploy ke web server (Apache/Nginx) dengan konfigurasi:
|
||||
|
||||
- Base URL: sesuai dengan domain production
|
||||
- API Base URL: otomatis terdeteksi dari hostname
|
||||
|
||||
### Update di Server Production
|
||||
|
||||
**Cara 1: Menggunakan Script (Recommended)**
|
||||
|
||||
```bash
|
||||
# Linux/Unix
|
||||
cd /path/to/retribusi-frontend
|
||||
@@ -72,17 +75,20 @@ pull.bat
|
||||
```
|
||||
|
||||
**Cara 2: Command Langsung (Sekali Jalan)**
|
||||
|
||||
```bash
|
||||
cd /path/to/retribusi-frontend && git stash && git pull origin main && git stash pop
|
||||
```
|
||||
|
||||
**Cara 3: Manual**
|
||||
|
||||
```bash
|
||||
cd /path/to/retribusi-frontend
|
||||
git pull origin main
|
||||
```
|
||||
|
||||
**Fix Dubious Ownership Error (jika muncul)**
|
||||
|
||||
```bash
|
||||
# Tambahkan directory ke safe.directory
|
||||
git config --global --add safe.directory /www/wwwroot/retribusi.btekno.cloud/retribusi
|
||||
@@ -90,4 +96,3 @@ git config --global --add safe.directory /www/wwwroot/retribusi.btekno.cloud/ret
|
||||
# Atau gunakan script pull.sh yang sudah auto-fix
|
||||
bash pull.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -69,7 +69,9 @@
|
||||
window.Auth = Auth;
|
||||
|
||||
// Jika sudah login, langsung arahkan ke dashboard utama (public/dashboard)
|
||||
if (Auth.isAuthenticated()) {
|
||||
// Cek dulu apakah kita sudah di dashboard untuk menghindari redirect loop
|
||||
const currentPath = window.location.pathname;
|
||||
if (Auth.isAuthenticated() && !currentPath.includes('dashboard.html')) {
|
||||
window.location.href = 'public/dashboard/dashboard.html';
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,11 @@ async function apiRequest(path, options = {}) {
|
||||
// Unauthorized → clear token & redirect to login
|
||||
localStorage.removeItem('token');
|
||||
localStorage.removeItem('user');
|
||||
// Cek apakah sudah di login page untuk menghindari redirect loop
|
||||
const currentPath = window.location.pathname;
|
||||
if (!currentPath.includes('index.php')) {
|
||||
window.location.href = '../index.php';
|
||||
}
|
||||
throw new Error('Unauthorized');
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,9 @@ async function handleLoginSubmit(event) {
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const form = document.getElementById('login-form');
|
||||
if (form) {
|
||||
if (Auth.isAuthenticated()) {
|
||||
// Cek apakah sudah authenticated dan belum di dashboard untuk menghindari redirect loop
|
||||
const currentPath = window.location.pathname;
|
||||
if (Auth.isAuthenticated() && !currentPath.includes('dashboard')) {
|
||||
window.location.href = 'dashboard.html';
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
<?php
|
||||
// Redirect ke login page di root
|
||||
header('Location: ../index.php');
|
||||
exit;
|
||||
|
||||
BIN
retribusi (frontend).zip
Normal file
BIN
retribusi (frontend).zip
Normal file
Binary file not shown.
Reference in New Issue
Block a user