title: Request blocked by CORS policy using superagent and a Lumen API
body: <p>I have create a REST API using PHP <a href="https://lumen.laravel.com/" rel="nofollow noreferrer">Lumen</a> framework to which I removed all CORS restriction for development using:</p>
  
  <pre class="lang-php prettyprint-override"><code>// Enable CORS on all API routes
  header('Access-Control-Allow-Origin: *');
  header("Access-Control-Expose-Headers: Content-Length, X-JSON");
  header('Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE, OPTIONS');
  header('Access-Control-Allow-Headers: Origin, Authorization, Lang, Content-Type, X-Auth-Token');
  </code></pre>
  
  <p>Then on the frontend I use the library <a href="https://github.com/visionmedia/superagent" rel="nofollow noreferrer">superagent</a> to call it . For example I call the route <code>POST http://127.0.0.1:8000/auth/register</code>:</p>
  
  <pre class="lang-js prettyprint-override"><code>superagent.post('http://127.0.0.1:8000/auth/register').send({
    name: 'name',
    email: 'test@test.test',
    password: '1234Test'
  }).type('application/json')
    .end((err, res) =&gt; {
      console.log(res)
      console.log(err)
    })
  </code></pre>
  
  <p>Sadly I get a CORS error message that I can't understand:</p>
  
  <blockquote>
    <p>Access to XMLHttpRequest at '<a href="http://127.0.0.1:8000/auth/register" rel="nofollow noreferrer">http://127.0.0.1:8000/auth/register</a>' from origin '<a href="http://localhost:9000" rel="nofollow noreferrer">http://localhost:9000</a>' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.</p>
  </blockquote>
  
  <p>I make some research but I can't find anything for the error <code>It does not have HTTP ok status</code> and testing this same request on Postman give me no error but the normal behaviour.</p>
  
  <p>Have someone an idea how I can solve it? Where I can find some documentation about this type of error?</p>