title: AWS - Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource
body: <p>I'm really new to AWS so please bear with me :(</p>
  
  <p>I'm currently making a web application that has a feature for uploading photos. I want to save these photos in S3 buckets and save a reference to them in my database. I am following this guide at the moment: <a href="http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/s3-example-photo-album.html" rel="noreferrer">http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/s3-example-photo-album.html</a></p>
  
  <p>However, I've done everything stated in the guide (or at least I hope), but when I run the app and run the <code>createAlbum()</code> method, I get the error:</p>
  
  <blockquote>
    <p>XMLHttpRequest cannot load <a href="https://my-bucket-name.s3-us-west-2.amazonaws.com/myalbumname/" rel="noreferrer">https://my-bucket-name.s3-us-west-2.amazonaws.com/myalbumname/</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://localhost:3000" rel="noreferrer">http://localhost:3000</a>' is therefore not allowed access.</p>
  </blockquote>
  
  <p>I made sure that permissions allowed for all users in the Bucket permissions, I updated the CORS config as instructed by the docs, and updated the role policy as well.</p>
  
  <p>This is my code in terms of credentials:</p>
  
  <blockquote>
    <p>var albumBucketName = 'my-bucket-name'; //not the real value, obviously</p>
    
    <p>var bucketRegion = 'us-west-2';</p>
    
    <p>var IdentityPoolId = 'my-identity-pool-id'; //here, too</p>
    
    <p>AWS.config.update({</p>
    
    <p>region: bucketRegion,</p>
    
    <p>credentials: new AWS.CognitoIdentityCredentials({</p>
    
    <p>IdentityPoolId: IdentityPoolId</p>
    
    <p>})</p>
    
    <p>});</p>
    
    <p>var s3 = new AWS.S3({
      apiVersion: '2006-03-01',
      params: {Bucket: albumBucketName}
    });</p>
  </blockquote>
  
  <p>I've been trying to find a solution with no success. Does anyone know what I need to do to fix this? Any help is greatly appreciated!
  Thank you.</p>