title: Cross-Origin Request Blocked At time of sending post request
body: <p>I have 2 servers and 2 domains I want to send a post request from one domain to another but my browser shows an error </p>
  
  <blockquote>
    <p>access to XMLHttpRequest at '<a href="https://example.com" rel="nofollow noreferrer">https://example.com</a>' from origin '<a href="https://www.example2.com" rel="nofollow noreferrer">https://www.example2.com</a>' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.</p>
  </blockquote>
  
  <p>the javascript code i am using To  send Post Data is </p>
  
  <pre><code>&lt;script&gt;
  var data = JSON.stringify({
    "key": "value sent"
  });
  var xhr = new XMLHttpRequest();
  xhr.withCredentials = true;
  xhr.addEventListener("readystatechange", function () {
    if (this.readyState === 4) {
      console.log(this.responseText);
    }
  });
  xhr.open("POST", "https://example.com");
  xhr.setRequestHeader("content-type", "application/json");
  xhr.setRequestHeader("cache-control", "no-cache");
  xhr.send(data);
  &lt;/script&gt;
  </code></pre>
  
  <p>So My question is how I can resolve this problem and send a Post request to another domain and which method to use to send post request </p>