Files
Retribusi/public/dashboard/js/README_CONFIG.md
BTekno Dev 5e330e931b Fix: Data inconsistency pada transisi tahun/bulan dan setup API lokal untuk testing
- Fix deteksi transisi bulan untuk semua bulan (tidak hanya 1 Januari)
- Perbaikan validasi data dengan threshold 20% untuk transisi bulan/tahun
- Auto-reset chart jika data hourly tidak valid
- Setup force local mode untuk testing API lokal
- Perbaikan normalisasi dan validasi tanggal
- Enhanced logging untuk debugging transisi
2026-01-01 23:38:42 +07:00

2.1 KiB

Konfigurasi API Base URL

Lokasi File

  • Config: public/dashboard/js/config.js
  • Digunakan oleh: api.js, realtime.js

Cara Kerja

File config.js akan auto-detect environment berdasarkan hostname:

Development Lokal (Auto-detect)

  • Jika hostname = localhost, 127.0.0.1, atau IP lokal (192.168.x.x, 10.x.x.x, 172.x.x.x)
  • Base URL: http://localhost/api-btekno/public
  • Otomatis menggunakan API lokal saat development

Production (Auto-detect)

  • Jika hostname bukan localhost/IP lokal
  • Base URL: https://api.btekno.cloud
  • Otomatis menggunakan API produksi saat di production

Cara Mengubah Base URL

Edit file public/dashboard/js/config.js:

function getApiBaseUrl() {
  const hostname = window.location.hostname;
  
  // Development lokal
  if (hostname === 'localhost' || hostname === '127.0.0.1') {
    // GANTI INI sesuai path API backend Anda
    return 'http://localhost/api-btekno/public';
    // Atau jika pakai virtual host:
    // return 'http://api.retribusi.test';
  }
  
  // Production
  return 'https://api.btekno.cloud';
}

Jika ingin hardcode, edit langsung di config.js:

export const API_CONFIG = {
  BASE_URL: 'http://localhost/api-btekno/public', // Ganti ini
  API_KEY: 'POKOKEIKISEKOYOLO',
  TIMEOUT: 30000
};

Contoh Path API Backend

Laragon

  • Jika API di: C:\laragon\www\RETRIBUSI_BAPENDA\api-btekno\public
  • Base URL: http://localhost/api-btekno/public
  • Atau buat virtual host: http://api.retribusi.test

XAMPP

  • Jika API di: C:\xampp\htdocs\api-btekno\public
  • Base URL: http://localhost/api-btekno/public

Production

  • Base URL: https://api.btekno.cloud

API Key

API Key juga bisa diubah di config.js:

API_KEY: 'POKOKEIKISEKOYOLO' // Sesuaikan dengan RETRIBUSI_API_KEY di backend .env

Debugging

Untuk melihat Base URL yang digunakan, buka browser console. Akan muncul log:

API Base URL: http://localhost/api-btekno/public