title: Access to fetch at *** from origin *** has been blocked by CORS policy: No 'Access-Control-Allow-Origin'
body: <p>I have error </p>
  
  <blockquote>
    <p>Access to fetch at '<a href="http://localhost:5000/admin/authenticate" rel="noreferrer">http://localhost:5000/admin/authenticate</a>' from origin '<a href="http://localhost:3000" rel="noreferrer">http://localhost:3000</a>' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.</p>
  </blockquote>
  
  <p>My ApiManager</p>
  
  <pre><code>function login(username, password) {
      const requestOptions = {
          method: 'POST',
          headers: {    
              'Accept': 'application/json',
              'Content-Type': 'application/json',
              'Access-Control-Allow-Origin': '*' },
          body: JSON.stringify({ username, password })};
  
      return fetch(`http://localhost:5000/admin/authenticate`, requestOptions)
          .then(handleResponse)
          .then(user =&gt; {
              // store user details and jwt token in local storage to keep user logged in between page refreshes
              localStorage.setItem('user', JSON.stringify(user));
              return user;
          }
      );
  }
  </code></pre>
  
  <p>In Backend Asp.Net Core 2.2 (Startup.cs) I write:</p>
  
  <pre><code>services.AddCors(options =&gt;
  {
      options.AddPolicy(
          _corsName,
          builder =&gt; { builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader().AllowCredentials(); });}
  );
  </code></pre>