title: Sending REST request from react application
body: <p>I'm trying to send REST request from rest application, but I'm getting 405 error.
  My domain supplier had advised me to change the web.config file.</p>
  
  <pre><code>&lt;system.webServer&gt;
    &lt;httpProtocol&gt;
      &lt;customHeaders&gt;
        &lt;add name="Access-Control-Allow-Origin" value="*" /&gt;
        &lt;add name="Access-Control-Allow-Headers" value="Content-Type" /&gt;
        &lt;add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" /&gt;
      &lt;/customHeaders&gt;
     &lt;/httpProtocol&gt;
  &lt;/system.webServer&gt;
  </code></pre>
  
  <p>I've also used Microsoft.AspNet.WebApi.cors, and added the line</p>
  
  <pre><code>config.EnableCors();
  </code></pre>
  
  <p>to WebApiConfig.cs
  and added the headers</p>
  
  <pre><code>[EnableCors(origins:"http://localhost:3000",headers:"*",methods:"*")]
  </code></pre>
  
  <p>to my controller Action.</p>
  
  <p>And on the client side I've tried using Fetch:</p>
  
  <pre><code> const payload = {
              dos: "window",
              did: "123456",
              phone: userName,
              password: password
          };
          const options = {
            method: 'POST',
            mode: 'cors',
            headers: {
              'Accept': 'application/json',
              'Content-Type': 'application/jsonp',
            },
            body: JSON.stringify(payload),
  
          };
  
          // SEND REQUEST
          fetch('myUrl/API/login_staff', options).then((response) =&gt; {
            console.log(response);
          }).catch((error) =&gt; {
            console.log(error)
          });  
  </code></pre>
  
  <p>But I'm getting the 505 error followed by:
  Failed to load <em>myUrl</em>: The 'Access-Control-Allow-Origin' header contains multiple values '<a href="http://localhost:3000" rel="nofollow noreferrer">http://localhost:3000</a>, *', but only one is allowed. Origin '<a href="http://localhost:3000" rel="nofollow noreferrer">http://localhost:3000</a>' is therefore not allowed access. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled
  How can I fix It? </p>