This commit is contained in:
2026-01-27 12:56:41 +05:30
parent deeecc6f9c
commit 70e1f85971
2 changed files with 40 additions and 7 deletions

View File

@@ -6,7 +6,7 @@
$API_HEADERS = [
'Content-Type: application/json; charset=utf-8',
'Access-Control-Allow-Origin: *',
'Access-Control-Allow-Methods: GET, POST, OPTIONS',
'Access-Control-Allow-Methods: POST, OPTIONS',
'Access-Control-Allow-Headers: Content-Type, Authorization',
'X-Powered-By: SiliconPin Tools'
];
@@ -14,9 +14,20 @@ $API_HEADERS = [
/**
* Apply headers helper
*/
function applyApiHeaders(array $headers)
function applyApiHeaders(array $headers): void
{
foreach ($headers as $header) {
header($header);
}
}
/**
* Handle CORS preflight globally
*/
function handleCorsPreflight(): void
{
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
http_response_code(200);
exit;
}
}