Initial commit: Retribusi frontend dengan dashboard, event logs, dan settings
This commit is contained in:
38
public/dashboard/js/config.js
Normal file
38
public/dashboard/js/config.js
Normal file
@@ -0,0 +1,38 @@
|
||||
// public/dashboard/js/config.js
|
||||
// Konfigurasi API Base URL untuk frontend
|
||||
|
||||
// Auto-detect environment berdasarkan hostname
|
||||
function getApiBaseUrl() {
|
||||
const hostname = window.location.hostname;
|
||||
|
||||
// Development lokal (Laragon/XAMPP)
|
||||
if (hostname === 'localhost' || hostname === '127.0.0.1' || hostname.startsWith('192.168.')) {
|
||||
// Untuk PHP built-in server (port 8000)
|
||||
// return 'http://localhost:8000';
|
||||
|
||||
// Untuk Laragon/Apache (path-based)
|
||||
// return 'http://localhost/api-btekno/public';
|
||||
|
||||
// Untuk Laragon virtual host
|
||||
// return 'http://api.retribusi.test';
|
||||
|
||||
// Default: PHP built-in server
|
||||
return 'http://localhost:8000';
|
||||
}
|
||||
|
||||
// Production
|
||||
return 'https://api.btekno.cloud';
|
||||
}
|
||||
|
||||
// Export config
|
||||
export const API_CONFIG = {
|
||||
BASE_URL: getApiBaseUrl(),
|
||||
API_KEY: 'POKOKEIKISEKOYOLO', // Sesuaikan dengan RETRIBUSI_API_KEY di backend
|
||||
TIMEOUT: 30000 // 30 detik
|
||||
};
|
||||
|
||||
// Untuk debugging
|
||||
if (typeof window !== 'undefined') {
|
||||
console.log('API Base URL:', API_CONFIG.BASE_URL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user