Initial commit: Retribusi frontend dengan dashboard, event logs, dan settings

This commit is contained in:
mwpn
2025-12-18 11:21:40 +07:00
commit b3573ed390
35 changed files with 7368 additions and 0 deletions

30
api/cors-handler.php Normal file
View File

@@ -0,0 +1,30 @@
<?php
/**
* CORS Handler untuk API Btekno
*
* File ini HARUS di-include di awal SETIAP endpoint PHP
* atau ditempatkan di file bootstrap/autoload yang dieksekusi sebelum semua endpoint
*
* Usage:
* require_once __DIR__ . '/cors-handler.php';
*/
// Set CORS headers
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
header("Access-Control-Allow-Headers: Content-Type, Authorization, X-API-KEY");
header("Access-Control-Max-Age: 3600");
header("Access-Control-Allow-Credentials: false");
// Handle preflight OPTIONS request
// Browser akan mengirim OPTIONS request sebelum POST/PUT/DELETE jika ada custom headers
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
http_response_code(200);
exit;
}
// Log untuk debugging (opsional, bisa dihapus di production)
if (defined('APP_DEBUG') && APP_DEBUG === true) {
error_log('CORS Handler: ' . $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI']);
}