title: has been blocked by CORS policy by using axios and fetch in react
body: <p>I'm trying to do a post request of a server but keep getting a CORS error using axios and fetch in React.</p>
  
  <p>the code:</p>
  
  <pre><code>fetch('https://api/entries', 
      { mode: 'no-cors',
        method: 'post',
        headers: {
          "Content-Type":"application/octet-stream",
          'Access-Control-Allow-Origin': true
        }, 
        body: JSON.stringify({
          "KEY":"VALUE"
        })
      })
  
    .then((response) =&gt; {
      console.log(response) 
    })
    .catch(err =&gt; console.log(err))
  </code></pre>
  
  <p>or </p>
  
  <pre><code>
  axios({
        method: 'post',
        url: 'https://api/entries',
        headers: {
          "Content-Type":"application/octet-stream",
          'Access-Control-Allow-Origin': true
        }, 
        data: {
              "KEY":"VALUE"
  
        }
      })
      .then(response =&gt; {
  
            console.log(response);
          })
      .catch(err =&gt; console.log(err));
  
  </code></pre>
  
  <p>axios console response</p>
  
  <pre><code>Access to XMLHttpRequest at 'https://api/entries' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
  </code></pre>
  
  <p>and the another</p>
  
  <p>Fetch console response</p>
  
  <pre><code>Cross-Origin Read Blocking (CORB) blocked cross-origin response https://api/entries with MIME type text/plain. See https://www.chromestatus.com/feature/5629709824032768 for more details.
  </code></pre>
  
  <p>Thanks</p>