title: Why does my http://localhost CORS origin not work?
body: <p>I am stuck with this CORS problem, even though I set the server (nginx/node.js) with the appropriate headers.</p>
  
  <p>I can see in Chrome Network pane -> Response Headers:</p>
  
  <pre><code>Access-Control-Allow-Origin:http://localhost
  </code></pre>
  
  <p>which should do the trick.</p>
  
  <p>Here's the code that I now use to test:</p>
  
  <pre><code>var xhr = new XMLHttpRequest();
  xhr.onload = function() {
     console.log('xhr loaded');
  };
  xhr.open('GET', 'http://stackoverflow.com/');
  xhr.send();
  </code></pre>
  
  <p>I get</p>
  
  <blockquote>
    <p>XMLHttpRequest cannot load <a href="http://stackoverflow.com/">http://stackoverflow.com/</a>. Origin <a href="http://localhost" rel="noreferrer">http://localhost</a> is not allowed by Access-Control-Allow-Origin.</p>
  </blockquote>
  
  <p>I suspect it's a problem in the client script and not server configuration...</p>