if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Headers' '*';
ddd_header 'Access-Control-Allow-Methods', '*';
return 204;
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Headers' '*';
ddd_header 'Access-Control-Allow-Methods', '*';
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Headers' '*';
ddd_header 'Access-Control-Allow-Methods', '*';
}
res.header('Access-Control-Allow-Methods', '*');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: *');
<?php
$filename = "data.json";
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json");
if (file_exists($filename)) {
print(file_get_contents($filename));
} else {
print(json_encode([]));
}
?>