一、允许所有
header("Access-Control-Allow-Origin: *");
二、允许某个
header("Access-Control-Allow-Origin: http://localhost:8080");
三、允许多个
$origin = ['http://localhost:8080','http://localhost:8081'];
$AllowOrigin = 'http://localhost:8080';
if(in_array($_SERVER["HTTP_ORIGIN"],$origin)){
$AllowOrigin = $_SERVER["HTTP_ORIGIN"];
}
header("Access-Control-Allow-Origin: ".$AllowOrigin );