php跨域处理
$allow_origin = array(
'http://xxxx',
);
$origin = isset($_SERVER['HTTP_ORIGIN']) ? $_SERVER['HTTP_ORIGIN'] : '';
if (in_array($origin, $allow_origin)) {
header('Access-Control-Allow-Origin:' . $origin);
}else{
header('Access-Control-Allow-Origin: *');
}
header('Access-Control-Allow-Headers:Content-Type');
header('Access-Control-Allow-Credentials:true');
header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization, Cookie, TEST-USER-ID, TEST-TOKEN,test-token,adt-user-id");
|