title: Facing a CORS ERROR in local server
body: <p>I'm sending a post request with <code>XMLHttpRequest</code> to my other domain in local but I get the CORS error below:</p>
  
  <blockquote>
    <p>Failed to load <a href="http://another.local/" rel="nofollow noreferrer">http://another.local/</a>: The 'Access-Control-Allow-Origin' header contains multiple values '*, <a href="http://example.local" rel="nofollow noreferrer">http://example.local</a>', but only one is allowed. Origin '<a href="http://example.local" rel="nofollow noreferrer">http://example.local</a>' is therefore not allowed access.</p>
  </blockquote>
  
  <p>I had set header in PHP as below:</p>
  
  <pre><code>&lt;?php
  header("Access-Control-Allow-Origin: *",false); //header("Access-Control-Allow-Origin: *");
  header('Access-Control-Allow-Methods: POST, GET');
  header("Access-Control-Allow-Credentials: true");
  header('Access-Control-Max-Age: 1000');
  header("Content-type:application/json");
  readfile('data.json');
  </code></pre>
  
  <p>Despite setting the header, I'm still getting the CORS error; what am I doing wrong and how can I fix it?</p>