mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-04-06 03:58:00 +08:00
added 支持CORS跨域请求,完善Ajax请求方式
This commit is contained in:
parent
9e09f3802e
commit
7f0f18a87e
@ -19,6 +19,7 @@ class Base extends Controller {
|
||||
public $url;
|
||||
public $menuInfo;
|
||||
|
||||
private $CORS = true;
|
||||
private $superUrl = [
|
||||
'User/login',
|
||||
'User/logout'
|
||||
@ -36,6 +37,14 @@ class Base extends Controller {
|
||||
if(method_exists($this,'_myInitialize')){
|
||||
$this->_myInitialize();
|
||||
}
|
||||
|
||||
if( $this->CORS ){
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header('Access-Control-Allow-Credentials: true');
|
||||
header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
|
||||
header('Access-Control-Allow-Headers: Content-Type, Content-Range, Content-Disposition, Content-Description');
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'xmlHttpRequest';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user