yii2 rest跨域

阅读更多
[
                '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'],
        ];
    }
}

 

你可能感兴趣的:(yii2 rest跨域)