0

Access to fetch at 'https://www.googleapis.com/calendar/v3/primary/events' from origin 'https://s3.amazonaws.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

I am trying to add an event onto my google calendar through the calendar API. I'm currently trying to run my code through my S3 bucket. I've tried adding an origin URI such as https://s3.amazonaws.com. Of course I've looked at other posts but have found no solution that would help with my problem.

I made a COR configuration within my bucket:

    [
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "PUT",
            "POST",
            "DELETE"
        ],
        "AllowedOrigins": [
            "https://s3.amazonaws.com"
        ],
        "ExposeHeaders": [
            "x-amz-server-side-encryption",
            "x-amz-request-id",
            "x-amz-id-2"
        ],
        "MaxAgeSeconds": 3000
    }
]

Even after doing that, the error persists. If anyone has any insight on this, it would be much appreciated. Thank you.

edit: I am no longer using http://localhost:8000

borchvm
  • 3,533
  • 16
  • 44
  • 45
James
  • 9
  • 2

1 Answers1

0

It looks you are running it locally on localhost:8000. You might want to search for the CORS (Cross-Origin Resource Sharing) documentation here: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS

Also, are you going to localhost:8000 or http://localhost:8000? You should not add http:// before localhost.

Edit: I found the accepted answer on this question might be helpful.

  • I am going to localhost:8000 on the browser, I used `http://localhost:8000`. as one of the authorized javascript origins URI's in my api, as it requires http:// as the scheme. Thank you I will take a look at the documentation. The post you referred to is something I have tried, but was sadly not successful. – James Apr 17 '23 at 01:50
  • It sounds like @ingoCollatz 's answer might help you. Also you can rent/buy a domain if you really wanted to but that costs money. You could also look at GitHub Pages for a free domain hosted on GitHub. – CuteMrMerp Apr 17 '23 at 01:52
  • For sure, I do have a domain, I'm just testing it on my local server before I move it up there. – James Apr 17 '23 at 02:03