title: Cors issues only when send headers
body: <p>I have vueJS running on <strong>http://localhost:8080</strong> and Lumen API running on <strong><a href="http://stockprise.test/" rel="nofollow noreferrer">http://stockprise.test/</a></strong> . I want to do the following request from vueJS to API:</p>
  <pre><code>    async log() {
            await fetch(&quot;http://stockprise.test/login&quot;, {
              method: &quot;POST&quot;,
              headers: {
                &quot;Content-Type&quot;: &quot;application/json&quot;
              },
              body: JSON.stringify({email:'test@gmail.com',password:'pass123'})
            }).then(
              function(response) {
                return response.text();
              },
              function(error) {
                error.message;
              }
            );
          }
  </code></pre>
  <p>but then I get the following error:</p>
  <p><a href="https://i.stack.imgur.com/CXHE3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CXHE3.png" alt="CORS policy" /></a></p>
  <p>This is the code for Cors in lumen</p>
  <pre><code>        class CorsMiddleware
      {
          /**
           * Handle an incoming request.
           *
           * @param  \Illuminate\Http\Request  $request
           * @param  \Closure  $next
           * @return mixed
           */
          public function handle($request, Closure $next)
          {
              $response = $next($request);
              $IlluminateResponse = 'Illuminate\Http\Response';
              $SymfonyResopnse = 'Symfony\Component\HttpFoundation\Response';
              $headers = [
                  'Access-Control-Allow-Origin' =&gt; '*',
                  'Access-Control-Allow-Methods' =&gt; 'POST, GET, OPTIONS, PUT, PATCH, DELETE',
                  'Access-Control-Allow-Headers' =&gt; 'Access-Control-Allow-Headers, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Authorization , Access-Control-Request-Headers',
              ];
              
              if($response instanceof $IlluminateResponse) {
                  foreach ($headers as $key =&gt; $value) {
                      $response-&gt;header($key, $value);
                  }
                  return $response;
              }
              
              if($response instanceof $SymfonyResopnse) {
                  foreach ($headers as $key =&gt; $value) {
                      $response-&gt;headers-&gt;set($key, $value);
                  }
                  return $response;
              }
              
              return $response;
          }
      }
  </code></pre>
  <p>And i call the Middleware in the bootstrap/app.php middlewareApp of lumen:</p>
  <pre><code>     $app-&gt;middleware([
          App\Http\Middleware\CorsMiddleware::class
      ]);
  </code></pre>
  <p>When I remove the headers in fetch it works perfectly but it sends the data in the form <strong>application/x-www-form-urlencoded</strong> so i have to add the <strong>&quot;Content-type&quot;:&quot;application/json&quot;</strong> ... Any help ?</p>