title: CORS error using fetch API - React create app
body: <p>I'm consuming an API using fetch but i'm getting CORS error. 
  I tried multiples headers, but I'm not understading what's the problem.</p>
  
  <p>I'm not the owner of the API, so I couldn't change it, but checking the response it's returning <code>access-control-allow-origin</code>. </p>
  
  <p>Following is my request method:</p>
  
  <pre><code>export const execPOST = (url, body) =&gt; {
    return fetch(url, {
      method: "POST",
      headers: {
        "Access-Control-Allow-Origin": "*",
        "Content-Type": "application/json"
      },
      body: JSON.stringify(body)
    });
  };
  </code></pre>
  
  <p>The response is:</p>
  
  <pre><code>Request URL: http://api
  Request Method: OPTIONS
  Status Code: 405 Method Not Allowed
  Remote Address: ip
  Referrer Policy: no-referrer-when-downgrade
  Response Headers:
  Access-Control-Allow-Origin: *
  </code></pre>
  
  <p>Isn't this response above enough to allow my request?</p>
  
  <p>console error:</p>
  
  <blockquote>
    <p>OPTIONS <code>http://api</code> net::ERR_ABORTED 405 (Method Not Allowed)
        Access to fetch at <code>'http://api'</code> from origin <code>'http://localhost:3000'</code> 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 got this working (meanwhile I develop) using <code>"https://cors-anywhere.herokuapp.com/"</code>, but I don't think that I should use this for production enviroment.</p>
  
  <p>I found a lot of material about this problem, but nothing that worked besides implements a backend to make the request or use something else as a proxy to make the request and so on... </p>