0

I am unable to create an S3 bucket, ERROR is -response to preflight request does not pass access control check: 'no access control allow origin' header is present on requested header while inserting bucket into aws. Please help out with this, Thanks in advance.

I am using following js code

<script type="text/javascript">
  /* AWS.config.update({
    accessKeyId: "************",
    secretAccessKey: "************************",
    region_config: "us-east-1" 
  });*/

  AWS.config.update({
    accessKeyId: "************",
    secretAccessKey: "************************"
  });

  function createAwsBucket() {
    alert('inside bucket');

    // Create S3 service object
    //s3 = new AWS.S3({apiVersion: '2006-03-01'});
    var s3 = new AWS.S3();

    // Create params for S3.createBucket
    var bucketParams = {
      Bucket : "testeinsteinvivek"
    };
    alert('after param'+bucketParams);

    // call S3 to create the bucket
    s3.createBucket(bucketParams, function(err, data) {
      alert('inside func');
      if (err) {
        alert('error'+err);
        alert('data'+data);
        console.log("Error", err);
      } else {
        alert('success');
        console.log("Success", data.Location);
      }
    });
  }
</script>
Khalid T.
  • 8,045
  • 4
  • 33
  • 46
  • seems like CORS issue - https://stackoverflow.com/questions/35588699/response-to-preflight-request-doesnt-pass-access-control-check – Amit Yadav Mar 27 '18 at 13:15
  • `AWS.config.update({ accessKeyId: "************", secretAccessKey: "************************" });` is not an acceptable practice in the browser. – Michael - sqlbot Mar 27 '18 at 20:20

0 Answers0