CORS error with S3 even after adding CORS configuration
<p>I am trying to upload images to an S3 bucket via javaScript. When submitting the request, the following error returns:</p>

<pre><code>XMLHttpRequest cannot load https://somebucket.s3-us-west 
2.amazonaws.com/albums//apicture.png. Response to preflight 
request doesn't pass access control check: No 'Access-Control-Allow-Origin'
header is present on the requested resource. 
Origin 'http://someorigin:3000' is therefore not allowed access.
</code></pre>

<p>My CORS configuration on the bucket:</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;http://someorigin:3000&lt;/AllowedOrigin&gt;
        &lt;AllowedOrigin&gt;*&lt;/AllowedOrigin&gt;
        &lt;AllowedMethod&gt;POST&lt;/AllowedMethod&gt;
        &lt;AllowedMethod&gt;GET&lt;/AllowedMethod&gt;
        &lt;AllowedMethod&gt;PUT&lt;/AllowedMethod&gt;
        &lt;AllowedMethod&gt;DELETE&lt;/AllowedMethod&gt;
        &lt;AllowedMethod&gt;HEAD&lt;/AllowedMethod&gt;
        &lt;AllowedHeader&gt;*&lt;/AllowedHeader&gt;
    &lt;/CORSRule&gt;
&lt;/CORSConfiguration&gt;
</code></pre>

<p>I even manually added the origin to the policy as you can see, along with <code>*</code>, but nothing seems to be working, and I'm not sure where to begin. </p>

<p>I examined the network pane in the Chrome Devtools and noticed that one of the XHR was <code>apicture.png</code>, and it had the following key information:</p>

<pre><code>Request URL:https://somebucket.s3-us-west-2.amazonaws.com/pics/apicture.png
Request Method:OPTIONS
Status Code:301 Moved Permanently
</code></pre>

<p>The <code>response</code> tab had some other important information:</p>

<pre><code>&lt;Error&gt;
&lt;Code&gt;PermanentRedirect&lt;/Code&gt;
&lt;Message&gt;The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.&lt;/Message&gt;
&lt;Bucket&gt;somebucket&lt;/Bucket&gt;
&lt;Endpoint&gt;somebucket.s3-us-west-1.amazonaws.com&lt;/Endpoint&gt;
&lt;RequestId&gt;
***************
&lt;/RequestId&gt;
&lt;/Error&gt;
</code></pre>

<p>So, it is clear that they want the region to be <code>us-west-1</code> however, if I change my <code>AWS.config</code> to that, throws a different error. Amazon's own guides say that the area "Northern California" are encoded as <code>us-west-2</code>, so I am not sure why there is this inconsistency. </p>