Files
Retribusi/api/cors_handler.php

22 lines
610 B
PHP
Raw Permalink Normal View History

<?php
/**
* CORS Handler - WAJIB di-include di awal SETIAP endpoint
*
* INSTRUKSI:
* 1. Copy file ini ke server API
* 2. Include di awal SETIAP file endpoint: require_once 'cors_handler.php';
* 3. Atau copy kode di bawah ke awal setiap endpoint
*/
// ================= CORS =================
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
header("Access-Control-Allow-Headers: Content-Type, Authorization, X-API-KEY");
// Handle preflight OPTIONS request
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
http_response_code(200);
exit;
}