title: Laravel 403 Error for API that previously worked
body: <p>as of yesterday, the code below worked. today, however, i had to run a php artisan config:cache command in laravel as i added a package and now my nice ionic app does not want to run connect to anything as i keep getting this 403 error. </p>
  
  <p>the error started after i installed "rap2hpoutre/laravel-log-viewer": "^0.19.1", and cached, but i don't think that has anything to do with it. i was pretty sure my cache was up to date prior to that.</p>
  
  <p>jwt produces the same error. </p>
  
  <p>previously, the app was working without a cors plugin. </p>
  
  <p>it provides me this error locally and on my server (as i had to cache there too). </p>
  
  <p>this error is different than previous errors i have gotten when debugging this.</p>
  
  <p>when i pulled the route <a href="http://xxx/api/home" rel="noreferrer">http://xxx/api/home</a> normally in chrome - it returns fine... same in postman</p>
  
  <p>Thanks for your help!</p>
  
  <p>THE ERROR</p>
  
  <p>OPTIONS <a href="http://xxx/api/home" rel="noreferrer">http://xxx/api/home</a> 403 (Forbidden)
  Failed to load <a href="http://xxx/api/home" rel="noreferrer">http://xxx/api/home</a>: Response for preflight does not have HTTP ok status.</p>
  
  <p>IONIC</p>
  
  <pre><code>basicGet_no_token(rl){
          console.log('basicGet - ' + this.base_url + rl);
          return new Promise((resolve, reject) =&gt; {
              this.http.get(this.base_url + rl, 
                  {headers: new HttpHeaders({
                      'Content': 'application/json',
                      'Accept': 'application/json',
                  })})
                  .subscribe(res =&gt; {console.log(res);resolve(res);}, (err) =&gt; {this.handleError(err);console.log(err);reject(err);});
          }); 
      }
  </code></pre>
  
  <p>LARAVEL</p>
  
  <pre><code>Route::group(['middleware' =&gt; ['addHeaders']], function () {
      Route::get('home', 'api\WelcomeController@home');
  });
  
  class addHeaders
  {
      public function handle($request, Closure $next)
      {
      if ($request-&gt;getMethod() == "OPTIONS") {
        return response(['OK'], 200)
          -&gt;withHeaders([
            'Access-Control-Allow-Origin' =&gt; '*',
            'Access-Control-Allow-Methods' =&gt; 'GET, POST, PUT, DELETE',
            'Access-Control-Allow-Credentials' =&gt; true,   
            'Access-Control-Allow-Headers' =&gt; 'Origin, Content-Type, X-Auth-Token, authorization, X-Requested-With'
          ]);
      }
  
      return $next($request)
          -&gt;header('Access-Control-Allow-Origin', '*')
          -&gt;header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE')
          -&gt;header('Access-Control-Allow-Credentials', true)
          -&gt;header('Access-Control-Allow-Headers', 'Origin, Content-Type, X-Auth-Token, authorization, X-Requested-With');
  
      }
  }
  
  class WelcomeController extends Controller
  {
    public function home()
    {
          $r['message']="Welcome!";
      $r['allow']=true;
      $p=compact('r');
      return response()-&gt;json($p, 200);
    }
  }
  
  
  class Kernel extends HttpKernel
  {
  
      protected $middlewareGroups = [
            'api' =&gt; [
              'throttle:60,1',
              'bindings',
          ],
      ];
  
      protected $routeMiddleware = [
          'auth'      =&gt; \Illuminate\Auth\Middleware\Authenticate::class,
          'auth.basic'  =&gt; \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
          'bindings'    =&gt; \Illuminate\Routing\Middleware\SubstituteBindings::class,
          'can'       =&gt; \Illuminate\Auth\Middleware\Authorize::class,
          'guest'     =&gt; \App\Http\Middleware\RedirectIfAuthenticated::class,
          'jwt'           =&gt; \App\Http\Middleware\JWT::class,
          'addHeaders'    =&gt; \App\Http\Middleware\addHeaders::class,
        'jwt.auth'    =&gt; \Tymon\JWTAuth\Middleware\GetUserFromToken::class,
        'jwt.refresh'   =&gt; \Tymon\JWTAuth\Middleware\RefreshToken::class,        
          'throttle'    =&gt; \Illuminate\Routing\Middleware\ThrottleRequests::class,
      ];
  }
  </code></pre>