fix: CORS改为回显Origin,去掉白名单限制和credentials

This commit is contained in:
2026-05-28 14:37:33 +08:00
parent 0f952a36a5
commit bcf604dc0a
+5 -5
View File
@@ -23,13 +23,13 @@ class Pcapi extends Controller{
parent::__construct(); parent::__construct();
// CORS headers // CORS headers
$origin = Request::instance()->header('origin'); $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){
if($origin && in_array($origin, $allowed)){
header('Access-Control-Allow-Origin: '.$origin); header('Access-Control-Allow-Origin: '.$origin);
header('Access-Control-Allow-Headers: token, Origin, X-Requested-With, Content-Type, Accept, Authorization'); } else {
header('Access-Control-Allow-Methods: POST,GET,PUT,DELETE,OPTIONS'); header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Credentials: true');
} }
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()){ if(Request::instance()->isOptions()){
exit(); exit();
} }