title: Express - Cannot retrieve api-key from request header
body: <p>I am working with Rest and <code>fetch()</code> API in browser to POST data with <code>x-api-key</code> header for authorization.
  I tested the API with Postman and <code>curl</code> and it works just fine:</p>
  <pre><code>curl --header &quot;X-API-KEY: my-api-key&quot; -d &quot;my-request-body&quot; -X POST http://localhost:8081/submit
  </code></pre>
  <p>However, It doesn't work with the fetch api. On Chrome:</p>
  <pre><code>  const response = await fetch(url, {
      method: 'POST',
      mode: 'no-cors',
      cache: 'no-cache',
      headers: {
        'x-api-key': 'my-api-key',
        'Accept': 'text/plain',
        'Content-Type': 'text/plain'
      },
      redirect: 'follow',
      referrerPolicy: 'no-referrer',
      body: 'my-request-body'
    });
  
  </code></pre>
  <p>I'm not able the retrieve the API key from request. In my express, router handler:</p>
  <pre><code>router.post('/submit', cors(), async (req,res, next) =&gt; {
    const apiKey = req.header('x-api-key');
    console.log(apiKey) // THIS GIVES undefined
    });
  </code></pre>
  <p><strong>No <code>x-api-key</code> header is present in <code>req.headers</code> object either.</strong> Kindly help</p>