fix: add CORS headers to Pcapi controller constructor
This commit is contained in:
@@ -18,6 +18,18 @@ use Waybill\WaybillRoulette;
|
|||||||
class Pcapi extends Controller{
|
class Pcapi extends Controller{
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct();
|
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)){
|
||||||
|
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');
|
||||||
|
}
|
||||||
|
if(Request::instance()->isOptions()){
|
||||||
|
exit();
|
||||||
|
}
|
||||||
$actionName = Request::instance()->action();
|
$actionName = Request::instance()->action();
|
||||||
if(in_array($actionName,['doregister'])){
|
if(in_array($actionName,['doregister'])){
|
||||||
if(Session::has('is_post') && Session::get($actionName.'_is_post') == 0){
|
if(Session::has('is_post') && Session::get($actionName.'_is_post') == 0){
|
||||||
|
|||||||
Reference in New Issue
Block a user