// 允许跨域请求的地址
'allowUrls' => [
'http://localhost:8080',
'http://192.168.2.224',
'http://192.168.2.224:8080',
'http://192.168.2.200',
'http://192.168.2.102:350',
'http://192.168.2.77',
'http://192.168.2.77:80',
],
public function _initialize()
{
//----------------服务端设置ajax允许访问的header头-----------------------------------
$origin = isset($_SERVER['HTTP_ORIGIN'])? $_SERVER['HTTP_ORIGIN'] : '';
$all = Config('allowUrls');
if(in_array($origin, $all)){
header('Access-Control-Allow-Origin:'.$origin);
header('Access-Control-Allow-Methods:POST,GET');
header('Access-Control-Allow-Headers:x-requested-with,content-type');
}
//--------------------------------------------------------------------------------
}