title: GET request result to CORS error in Lumen 8
body: <p>I have this CORS problem when Axios sending <code>GET</code> HTTP to my Lumen app, sending <code>POST</code> HTTP seems fine. I have this middleware who's handling the CORS, below is the code</p>
  <pre><code>&lt;?php namespace App\Http\Middleware;
  
      use Closure;
  
      class CorsMiddleware{
       /**
       * Handle an incoming request.
       *
       * @param  \Illuminate\Http\Request  $request
       * @param  \Closure  $next
       * @return mixed
       */
      public function handle($request, Closure $next)
      {
          $headers = [
              'Access-Control-Allow-Origin'      =&gt; '*',
              'Access-Control-Allow-Methods'     =&gt; 'POST, GET, OPTIONS, PUT, DELETE',
              'Access-Control-Allow-Credentials' =&gt; 'true',
              'Access-Control-Max-Age'           =&gt; '86400',
              'Access-Control-Allow-Headers'     =&gt; 'Content-Type, Authorization, X-Requested-With'
          ];
  
          if ($request-&gt;isMethod('OPTIONS'))
          {
              return response()-&gt;json('{&quot;method&quot;:&quot;OPTIONS&quot;}', 200, $headers);
          }
  
          $response = $next($request);
          foreach($headers as $key =&gt; $value)
          {
              $response-&gt;header($key, $value);
          }
  
          return $response;
      }
  }
  </code></pre>
  <p>then added to <code>bootstrap/app.php</code></p>
  <pre><code>$app-&gt;middleware([
      App\Http\Middleware\CorsMiddleware::class, // cors middleware
  ]);
  </code></pre>
  <p>with a <code>POST</code> request, everything is working but when doing a <code>GET</code> request, a CORS error occurs. Any help, ideas are greatly appreciated, thanks in advance.</p>
  <p>My frontend app is running on <code>http://localhost:3000</code> (NUXT) and the Lumen app is running on <code>http://localhost:8000</code></p>
  <p>Below image is the screenshot of the error.
  <a href="https://i.stack.imgur.com/jX5Ke.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jX5Ke.png" alt="enter image description here" /></a></p>