📜  禁用 cors 策略 symfony - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:22.180000             🧑  作者: Mango

代码示例1
//his code in the file public/index.php work perfectly.

header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method");
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");
header("Allow: GET, POST, OPTIONS, PUT, DELETE");
$method = $_SERVER['REQUEST_METHOD'];
if ($method == "OPTIONS") {
    die();
}

https://stackoverflow.com/a/60642286/7610978