title: CORS policy error connecting to chat.postMessage in slack api with headers set and not set in React and Redux
body: <p>I was trying to send a message to slack api using React and axios, and due to some unknown reasons I'm getting CORS policy error.</p>
  
  <pre><code>export const sendMessage = data =&gt; dispatch =&gt; {
      console.log(data);
      const message = {
          channel: data.currentChannelId,
          text: data.text
      };
      const token =
          "MY_TOKEN";
  
      const config = {
          "Content-Type": "application/json",
          "Authorization": `Bearer ${token}`
      };
      axios
          .post("https://slack.com/api/chat.postMessage", JSON.stringify(message), config)
          .then(res =&gt; {
              console.log(res);
              dispatch({
                  type: actionTypes.SEND_MESSAGE,
                  payload: data
              });
          })
          .catch(err =&gt;
              dispatch({
                  type: actionTypes.SEND_MESSAGE,
                  payload: {}
              })
          );
  };
  </code></pre>
  
  <p>I have checked lot's of questions asked in here, and also contacted the support of slack, and got the following message:</p>
  
  <blockquote>
    <p>We've seen developers getting better results by making sure they're
    not sending any headers along with their request? This can cause
    preflight errors on our end.</p>
    
    <p>Could you try and see if that helps?</p>
  </blockquote>
  
  <p>Of course, not sending any headers is impossible as we are sending Authorization in our headers, too.</p>
  
  <p>I tried removing just <code>"Content-Type": "application/json"</code>, and again the same error occured. Also I tried changing it to <code>"Content-Type": "application/x-www-form-urlencoded"</code></p>
  
  <p>No changes happens in either cases. 
  I get this error:</p>
  
  <blockquote>
    <p>Access to XMLHttpRequest at '<a href="https://slack.com/api/chat.postMessage" rel="nofollow noreferrer">https://slack.com/api/chat.postMessage</a>'
    from origin '<a href="http://localhost:3000" rel="nofollow noreferrer">http://localhost:3000</a>' has been blocked by CORS policy:
    Request header field content-type is not allowed by
    Access-Control-Allow-Headers in preflight response.</p>
  </blockquote>
  
  <p>Although there are lot's of other questions, and this might be a duplicate, but none of the answers fit my problem.</p>