title: Access-Control-Allow-Origin error on AWS server when website is opened through www
body: <p>In browser when I am opening my website by typing <strong>only mywebsite.com</strong>,the ajax request successfully hits my rest webservice. But when I type <strong>www.mywebsite.com</strong>,then I get error as-<em>XMLHttpRequest cannot load <a href="http://mywebsite.com/path" rel="nofollow noreferrer">http://mywebsite.com/path</a> Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '<a href="http://www.mywebsite.com" rel="nofollow noreferrer">http://www.mywebsite.com</a>' is therefore not allowed access.</em></p>
  
  <p>The Jquery ajax request is-</p>
  
  <blockquote>
    <p>return $.ajax({
    url: "<a href="http://mywebsite.com/path/" rel="nofollow noreferrer">http://mywebsite.com/path/</a>",
    type: "POST",</p>
  </blockquote>
  
  <p>The website is deployed on <strong>AWS server</strong>,and below are the CORS configuration</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"&gt;
  &lt;CORSRule&gt;
      &lt;AllowedOrigin&gt;*&lt;/AllowedOrigin&gt;
      &lt;AllowedMethod&gt;GET&lt;/AllowedMethod&gt;
      &lt;AllowedMethod&gt;PUT&lt;/AllowedMethod&gt;
      &lt;AllowedMethod&gt;POST&lt;/AllowedMethod&gt;
      &lt;AllowedMethod&gt;DELETE&lt;/AllowedMethod&gt;
      &lt;MaxAgeSeconds&gt;3000&lt;/MaxAgeSeconds&gt;
      &lt;ExposeHeader&gt;x-amz-server-side-encryption&lt;/ExposeHeader&gt;
      &lt;ExposeHeader&gt;x-amz-request-id&lt;/ExposeHeader&gt;
      &lt;ExposeHeader&gt;x-amz-id-2&lt;/ExposeHeader&gt;
      &lt;AllowedHeader&gt;*&lt;/AllowedHeader&gt;
  &lt;/CORSRule&gt;
  &lt;/CORSConfiguration&gt;
  </code></pre>
  
  <p>I am unable to find the solution as why adding www creates problem.</p>