yii2 rest跨域
<?php /** * Created by PhpStorm. * User: hetao * Date: 2018/1/13 * Time: 20:44 */ namespace frontend\controllers; use yii\rest\ActiveController; use yii\filters\Cors; class CustomerController extends ActiveController { public $modelClass = 'common\models\Customer'; public function behaviors() { return [ 'corsFilter'=>[ 'class' => Cors::className(), 'cors'=>['Access-Control-Allow-Credentials' => true, 'Origin' => ['*'], 'Access-Control-Request-Method' => ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS'], 'Access-Control-Request-Headers' => ['*'], 'Access-Control-Allow-Credentials' => true, 'Access-Control-Max-Age' => 86400, 'Access-Control-Expose-Headers' => [], ] ] ]; } protected function verbs() { return [ 'index' => ['OPTIONS','GET', 'HEAD'], 'view' => ['OPTIONS','GET', 'HEAD'], 'create' => ['OPTIONS','POST'], 'update' => ['OPTIONS','PUT', 'PATCH'], 'delete' => ['OPTIONS','DELETE'], ]; } }
相关推荐
WasteLand 2020-10-18
Allinputs 2020-08-30
Ashes 2020-06-14
caiyiii 2020-06-14
kxguan 2020-06-14
daillo 2020-06-14
一粒沙里的世界 2020-06-14
ruxingli 2020-06-14
csssy00 2020-06-14
阿佐 2020-06-14
NameWFY 2020-05-28
NameWFY 2020-05-26
Robin罗兵 2020-05-16
caiyiii 2020-04-29
wmsjlihuan 2020-04-26
cbao 2020-04-26
csssy00 2020-04-19
igogo00 2020-03-09