REST OptionsAction() won't return


I’m using Yii2 to build a REST API. When there’s a preflight request (with OPTIONS method) coming I see that OptionsAction() sets the corresponding “Allow” headers. However after that it lets the script run further, so the actual action will run and after the real request comes (for example a POST request), the action will run again.

Why isn’t there a “return” or a “Yii::$app->end()” present in OptionsAction()? Now, because of the fact that the actual action runs twice it takes double time for a pageload.

Also, how could I overwrite this OptionsAction() function?