Answer the question
In order to leave comments, you need to log in
How to properly configure yii2 CORS filter to work with Reakt?
Good afternoon.
We are trying to set up a cors filter for yii2 so that we do not have to make additional crutches.
Now it looks like this:
'corsFilter' => [
'class' => Cors::class,
'cors' => [
'Origin' => ['*'],
'Access-Control-Request-Method' => ['OPTIONS', 'GET', 'POST'],
'Access-Control-Request-Headers' => ['Authorization,DNT,Keep-Alive,User-Agent,X-CustomHeader,X-Requested-With,If-Modified-Since,Cache-Control,Range,Content-Type'],
'Access-Control-Allow-Credentials' => true,
'Access-Control-Max-Age' => 3600,
'Access-Control-Expose-Headers' => ['Content-Length,Content-Range'],
],
],
public function beforeAction($action)
{
\Yii::$app->response->headers->add('Access-Control-Allow-Headers', 'Authorization,DNT,Keep-Alive,User-Agent,X-CustomHeader,X-Requested-With,If-Modified-Since,Cache-Control,Range,Content-Type');
return parent::beforeAction($action);
}
Request header field Content-Type is not allowed by Access-Control-Allow-Headers in preflight response.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question