polish the api route, response, health, cache, and metrics

This commit is contained in:
dwindown
2025-08-31 20:45:24 +07:00
parent ce001bf9ce
commit 726f5a842f
12 changed files with 627 additions and 97 deletions

View File

@@ -0,0 +1,17 @@
<?php
// app/helpers/cors.php
function cors_allow() {
$allowed = cfg('allowed_origins', []);
$origin = $_SERVER['HTTP_ORIGIN'] ?? '';
if ($origin && in_array($origin, $allowed, true)) {
header("Access-Control-Allow-Origin: {$origin}");
header("Vary: Origin");
}
header("Access-Control-Allow-Headers: Content-Type, X-Account-Id, X-License-Key, X-Dewemoji-Frontend, X-Dewemoji-Plan");
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
}
function cors_preflight() {
cors_allow();
http_response_code(204);
}
cors_allow();