public/index.php line 4
<?php
use App\Kernel;
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
$method = $_SERVER['REQUEST_METHOD'];
$allowedOrigins = [
'https://kindaka-frontend.vercel.app',
'http://localhost:3030/', // Add more origins here
];
if ($method === 'OPTIONS') {
// $origin = $_SERVER['HTTP_ORIGIN'];
// if (in_array($origin, $allowedOrigins)) {
header("Access-Control-Allow-Origin: *");
header('Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, PATCH, DELETE');
header('Access-Control-Allow-Headers: X-API-KEY,locale,lang, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method, Authorization');
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Max-Age: 86400'); // Cache the preflight response for 24 hours (optional)
http_response_code(204); // Set HTTP status code 204 (No Content) for the preflight response
// }
exit;
}
// $origin = $_SERVER['HTTP_ORIGIN'];
// if (in_array($origin, $allowedOrigins)) {
header("Access-Control-Allow-Origin: *");
header('Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, PATCH, DELETE');
header('Access-Control-Allow-Headers: X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method, Authorization');
header('Access-Control-Allow-Credentials: true');
// }
return function (array $context) {
return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
};