title: react Access to XMLHttpRequest has been blocked by CORS policy No 'Access-Control-Allow-Origin' header is present on the requested resource
body: <p>i am trying to access data from an api but i got this error</p>
  
  <p><strong>Access to XMLHttpRequest at '<a href="http://example.com/api/login" rel="nofollow noreferrer">http://example.com/api/login</a>' from origin '<a href="http://localhost:3000" rel="nofollow noreferrer">http://localhost:3000</a>' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.</strong></p>
  
  <p>this is my code</p>
  
  <pre><code>return axios.post('http://example.com/api/login', { username: username, password: password }).then(response =&gt; {
          console.log('response', response);
  
          if (response.status === 400 || response.status === 500)
              throw response.data;
          return response.data;
      }).catch(err =&gt; {
          console.log('err', err);
  
          throw err[1];
      });
  </code></pre>
  
  <p>Backend built with asp.net</p>
  
  <p>Thank you</p>