So I have created RESTful Yii using the class \yii\rest\ActiveController by following the tutorial from the Guide (http://www.yiiframework.com/doc-2.0/guide-rest-quick-start.html)
To enable the CORS, I add following code inside my controller class.
public function behaviors()
{
$parentBehaviors = parent::behaviors();
$cors =[
'corsFilter' => [
'class' => \yii\filters\Cors::className(),
'cors'=> [
'Origin' => ['*'],
'Access-Control-Request-Method' => ['GET', 'POST', 'PUT','PATCH', 'DELETE', 'HEAD', 'OPTIONS'],
'Access-Control-Request-Headers' => ['*'],
'Access-Control-Allow-Credentials' => null,
'Access-Control-Max-Age' => 86400,
]
],
];
$newBehaviors = $cors + $parentBehaviors;
return $newBehaviors;
}
I can GET, POST, DELETE to the Yii server. But somehow I can’t send PUT to the server. It says “Cross-Origin Request Blocked”. Why is that?