fix: CORS改为回显Origin,去掉白名单限制和credentials
This commit is contained in:
@@ -23,13 +23,13 @@ class Pcapi extends Controller{
|
||||
parent::__construct();
|
||||
// CORS headers
|
||||
$origin = Request::instance()->header('origin');
|
||||
$allowed = ['https://ww1.g7g7.top','https://m.g7g7.top','https://m1.g7g7.top','https://m3.g7g7.top','https://p.g7g7.top'];
|
||||
if($origin && in_array($origin, $allowed)){
|
||||
if($origin){
|
||||
header('Access-Control-Allow-Origin: '.$origin);
|
||||
header('Access-Control-Allow-Headers: token, Origin, X-Requested-With, Content-Type, Accept, Authorization');
|
||||
header('Access-Control-Allow-Methods: POST,GET,PUT,DELETE,OPTIONS');
|
||||
header('Access-Control-Allow-Credentials: true');
|
||||
} else {
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
}
|
||||
header('Access-Control-Allow-Headers: token, Origin, X-Requested-With, Content-Type, Accept, Authorization');
|
||||
header('Access-Control-Allow-Methods: POST,GET,PUT,DELETE,OPTIONS');
|
||||
if(Request::instance()->isOptions()){
|
||||
exit();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user