// 指定允许其他域名访问
$http = isset($_SERVER['HTTP_ORIGIN']) ? $_SERVER['HTTP_ORIGIN'] : '*';
header("Access-Control-Allow-Origin: {$http}");
// 响应类型
header("Access-Control-Allow-Methods: GET, POST");
// 设置是否允许发送 cookies
header("Access-Control-Allow-Credentials: true");
// 传递json参数,需要另外配置这个
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, x-file-name");