question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No 'Access-Control-Allow-Origin' header is present on the requested resource

See original GitHub issue

Hi guys,

it’s been some days with me trying to find out what’s wrong. I’ve been trying the lepozepo:s3 upload, and now the slingshot, to upload files to my bucket.

I’m using the root key access, to be sure that I’ve got all the privileges.

I’ve created a new app from scratch, still with insecure and auto-publish. The cors and bucket policy in the s3 bucket’s properties are as in the example.

Here’s my JS:


if (Meteor.isClient) {

    var uploader = new Slingshot.Upload("");

    Template.hello.events({
        "click button.upload": function () {


            var files = $("input.file_bag")[0].files;
            console.log(files);

            uploader.send(files[0], function (error, downloadUrl) {
                if (error) {
                    // Log service detailed response
                    console.error('Error uploading');
                    alert(error);
                } else {
                    console.log(downloadUrl);
                }
            });

        }
    });
}

if (Meteor.isServer) {


    Slingshot.createDirective("", Slingshot.S3Storage, {
        bucket: "meteor-bucket",

        acl: "public-read",

        authorize: function () {
            //Deny uploads if user is not logged in.
            //            if (!this.userId) {
            //                var message = "Please login before posting files";
            //                throw new Meteor.Error("Login Required", message);
            //            }

            return true;
        },

        maxSize: null,
        allowedFileTypes: ["image/png", "image/jpeg", "image/gif"],
        key: function (file) {
            //Store file into a directory by the user's username.
            return "ciao";
        },
        AWSAccessKeyId: "my_key",
        AWSSecretAccessKey: "my-key",
        region:"eu-west-1"
    });
}

after all the troubles, I’ve managed to solve everything. And now, as with the lepozepo:s3, the error in the console of the browser is:

XMLHttpRequest cannot load https://meteor-bucket.s3-eu-west-1.amazonaws.com/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://slingshots3test.meteor.com' is therefore not allowed access.

the only difference with the lepozepo:s3 package is the link of the bucket

any suggestions please?

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
kolya182commented, Sep 21, 2017

In my case I added: <ExposeHeader>ETag</ExposeHeader> to CORSRules

1reaction
aadamsxcommented, Sep 26, 2015

Did you get this figured out? I had the same issue. But since i’m in the US I had to change my region to region: “us-east-1” and things started working.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reason: CORS header 'Access-Control-Allow-Origin' missing
The response to the CORS request is missing the required Access-Control-Allow-Origin header, which is used to determine whether or not the ...
Read more >
Why does my JavaScript code receive a "No 'Access-Control ...
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. I know that the API or remote ......
Read more >
Fixing "No 'Access-Control-Allow-Origin' Header Present"
This error occurs when a script on your website/web app attempts to make a request to a resource that isn't configured to accept...
Read more >
3 Ways to Fix the CORS Error — and How the Access-Control ...
For every request, it will add the Access-Control-Allow-Origin: * header to the response. It tricks the browser, and overrides the CORS ...
Read more >
Resolve the "No 'Access-Control-Allow-Origin' header" error ...
Resolution. Confirm the origin's cross-origin resource sharing (CORS) policy allows the origin to return the Access-Control-Allow-Origin header.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found