跨域请求后端配置

$origin = isset($_SERVER['HTTP_ORIGIN'])? $_SERVER['HTTP_ORIGIN'] : '';

$allowOrigin = [
    'https://xx.com',
    'https://xx2.com',
    'http://xx.com',
];

if (in_array($origin, $allowOrigin)) {
    header("Access-Control-Allow-Origin:".$origin);
}

header('Access-Control-Allow-Headers: X-Requested-With,X_Requested_With');

header('Content-type: text/json; charset=utf-8');

header('Access-Control-Allow-Methods: POST,GET');
本作品采用《CC 协议》,转载必须注明作者和本文链接
focus
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!