title: Yii2 Rest - Custom action and OPTIONS method
body: <p>I'm having trouble with the following action "/login" route action in my UsersController class</p>
  
  <pre><code>public function actionLogin(){
          $data = Yii::$app-&gt;getRequest()-&gt;getBodyParams();
          $model = new Usuario();
  
          //Validamos que se hayan recibido los campos
          if(empty($data['email']) || empty($data['password'])){
              throw new \yii\web\BadRequestHttpException("Debe ingresar email y password");
          }
  
          //Validamos usuario y contraseña
          $usuario = $model-&gt;findByUsername($data['email']);
          if(empty($usuario) || !$usuario-&gt;validatePassword($data['password'])){
              throw new \yii\web\UnauthorizedHttpException("Usuario y/o contraseña incorrectos");
          }
          return $usuario;
      }
  </code></pre>
  
  <p>The situation is that I'm using POST method to perform login, and I'm calling this route from a different domain, so the frontend library first try to call /login route with OPTIONS method to check if it is allowed or not to call /login with POST..</p>
  
  <p>The problem is that the built in functionality of yii2 rest ActiveController is only for /users and /users/{id}</p>
  
  <p>If I manually add this /login route to be available in both POST and OPTIONS through actions verbFilter, then yii Is trying to actually call the login action with the OPTIONS request. I mean, it is trying to perform login. Of course it can't, because it is not sending email and passwords fields, but I can see an error in the log file.</p>
  
  <p>So, my question is... Is there any way to configure correctly this "custom" routes actions and make OPTIONS performs transparently? Because I'm expecting that login action not get executed when calling it with OPTIONS, but instead to return directly the OPTIONS allowed methods headers.</p>
  
  <p><strong>Update Info: Added URL manager rules</strong></p>
  
  <pre><code>'urlManager' =&gt; [
          'enablePrettyUrl' =&gt; true,
          'enableStrictParsing' =&gt; true,
          'showScriptName' =&gt; true,
          'rules' =&gt; [
              [
                  'class' =&gt; 'yii\rest\UrlRule', 
                  'controller' =&gt; ['v1/users'],
                  'pluralize' =&gt; false,
                  'tokens' =&gt; [
                      '{id}' =&gt; '&lt;id:\\w+&gt;'
                  ]
              ],
              //Rutas usuario
              'v1/login' =&gt; '/v1/users/login'
          ],        
      ],
  </code></pre>