Answer the question
In order to leave comments, you need to log in
Why does the status code 302 come with an OPTIONS request?
I am developing a site on YII2, from the frontend I am making a CORS OPTIONS request to an action email. I get 302 in response.
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'only' => ['login', 'remind', 'logout', 'phone-confirmation', 'registration', 'password', 'phone', 'email', 'payments', 'templates', 'template', 'email-confirmation', 'feed', 'get-points', 'get-count-payment'],
'rules' => [
[
'actions' => ['phone-confirmation', 'email-confirmation', 'get-points', 'feed', 'login', 'get-count-payment'],
'allow' => true,
'roles' => ['?', '@'],//all users
],
[
'actions' => ['remind', 'registration'],
'allow' => true,
'roles' => ['?'],//only guests
],
[
'actions' => ['password', 'phone', 'email', 'payments', 'templates', 'template', 'logout'],
'allow' => true,
'roles' => ['@'],//only logged users
]
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'login' => ['post', 'options'],
'remind' => ['post', 'options'],
'logout' => ['get'],
'phone-confirmation' => ['post', 'options'],
'registration' => ['post', 'options'],
'password' => ['post', 'options'],
'phone' => ['post', 'options'],
'email' => ['post', 'options'],
'email-confirmation' => ['get'],
'payments' => ['get'],
'templates' => ['get'],
'template' => ['post', 'put', 'delete', 'get', 'options'],
'get-points' => ['get'],
'get-count-payment' => ['get'],
'feed' => ['post', 'options'],
],
],
'corsFilter' => [
'class' => Cors::className(),
'cors' => [
'Origin' => ['*'],
'Access-Control-Request-Method' => ['GET', 'POST', 'PUT', 'OPTIONS'],
'Access-Control-Request-Headers' => ['*'],
'Access-Control-Allow-Credentials' => true,
]
],
];
}
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