title: Why Access-Control-Allow-Origin is necessary for same domain?
body: <p>I have my web application deployed on Web Sphere Server.</p>
  
  <p>I also have my HTML pages present as web content on Apache. These web pages are trying to grab the response from the service deployed on Web Sphere using AJAX. While doing this I get error on browser console saying <code>No 'Access-Control-Allow-Origin' header is present on the requested resource.</code></p>
  
  <p>Both the servers Apache, Web Sphere are running on the same machine but just different ports (of course). Then why is the question of allowing origin comes? Can someone please explain?</p>
  
  <p>To be more precise:</p>
  
  <p><code>http://localhost:8080/someHtmlPage.html</code> is making an AJAX call to service deployed at <code>http://localhost:9081/someContext/someService</code> for consuming the response.</p>
  
  <p>Most of the links I have seen have this problem because their domain is different but in my case the domain should remain the same.</p>
  
  <p>I have looked at <a href="https://stackoverflow.com/questions/1653308/access-control-allow-origin-multiple-origin-domains">this</a> and <a href="https://security.stackexchange.com/questions/43639/why-is-the-access-control-allow-origin-header-necessary">this</a></p>
  
  <p>Another question I have is making Access-Control-Allow-Origin entry with <code>*</code> solves the issue?</p>