title: XMLHttpRequest cannot load https://..... Response for preflight is invalid (redirect) for $http post request
body: <p>Here is my angularjs $http post request</p>
  
  <pre><code>    $http({
          method: 'POST',
          url: 'https://...',
          data: {matric:u.matric, faculty:u.faculty, department:u.department, level:u.level, password:u.password},
  
  
        }).success(function(){
        $scope.passwor = '';
         $scope.erro = '';
          $scope.matri = '';
      $state.go('login');
    }).error(function(error){
      console.log(error);
        $scope.erro = 'Please Try Again. Check Your Connection ';
             $scope.matri =error.matric[0];
       $scope.passwor =error.password[0];
  
  
    }).finally(function() { 
      loader.hide();
      });  
  </code></pre>
  
  <p>my api is written in lumen and i have added palanik/lumencors already to all the routes.
  I have also search for solution online but nothing seems to work for me. please help !!!.ihave this in my controller</p>
  
  <pre><code>public function option()
      {
        return true;
      }
  </code></pre>
  
  <p>and this in my route.php</p>
  
  <pre><code> $app-&gt;options('/', 'matricController@option');
      $app-&gt;post('/','matricController@store');
  </code></pre>
  
  <p>also this code that return okay(200) for OPTIONS</p>
  
  <pre><code> public function handle($request, Closure $next) {
          if ($request-&gt;isMethod('OPTIONS')) {
              $response = new Response("", 200);
          }
          else {
              $response = $next($request);
          }
          $this-&gt;setCorsHeaders($request, $response);
          return $response;
      }
  </code></pre>