connect_error) { die(json_encode(['success' => false, 'message' => 'Koneksi database gagal: ' . $conn->connect_error])); } $conn->set_charset('utf8mb4'); return $conn; } // Set header untuk API header('Content-Type: application/json'); header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS'); header('Access-Control-Allow-Headers: Content-Type'); if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') { exit(0); } ?>