public function _initialize(){
//开启跨域请求头信息
header('content-type:application:json;charset=utf8');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');
header("Access-Control-Allow-Methods: POST,GET");
header('Access-Control-Allow-Credentials:true');
$encrypt_str = 'gfhshshs';//盐字段 MDAwMDAwMDAwMIydhnQ
$encrypt = input('encr');//接收加密字符串
if(empty($encrypt)) $this->return_ajax('500','非法请求!','');
$res = $this -> decrypt($encrypt);//解密
if($res != $encrypt_str){
$this->return_ajax('500','非法请求!','');
}
}
php后台处理跨域问题
最新推荐文章于 2022-04-01 00:10:16 发布