php接口跨域
$domains = [
'http:**********',//放入跨域访问的域名
];
$origin = isset($_SERVER['HTTP_ORIGIN']) ? $_SERVER['HTTP_ORIGIN'] : '';
if (in_array($origin, $domains)) {
header('Access-Control-Allow-Origin:' . $origin);
}
// 允许的请求头信息
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization");
//在请求头里加上需要允许的 header("Access-Control-Allow-Headers: Origin, 名称);
// 允许的请求类型
header('Access-Control-Allow-Methods: GET, POST, PUT,DELETE,OPTIONS,PATCH');
// 允许携带证书式访问(携带cookie)
header('Access-Control-Allow-Credentials:true');