isotropic-2022
Share
Blog
Search
Menu

Fix AWS' S3 Access-Control-Allow-Origin Header Error

By James LePage
 on January 29, 2021
Last modified on January 6th, 2022

Fix AWS' S3 Access-Control-Allow-Origin Header Error

By James LePage
 on January 29, 2021
Last modified on January 6th, 2022

If you're trying to publicly distribute files from an Amazon S3 bucket, you may have come across this error in the past:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at your-s3-bucket.com. (Reason: CORS request did not succeed).Code language: CSS (css)

In the new (2020) S3 interface/dashboard, you need to write the header as a JSON. This code will fix the S3 Access-Control-Allow-Origin Header, allowing for GET requests from any domain.

[ { "AllowedHeaders": [ "*" ], "AllowedMethods": [ "GET", "HEAD" ], "AllowedOrigins": [ "*" ], "ExposeHeaders": [], "MaxAgeSeconds": 3000 } ]

This code is placed in the Cross-origin resource sharing (CORS) section of the permissions tab for your specific bucket.

On the dashboard, it would look like this:

How to fix the annoying "aws cors header ‘access-control-allow-origin’ missing"

Further reading: https://stackoverflow.com/questions/17533888/s3-access-control-allow-origin-header

Subscribe & Share
If you liked this content, subscribe for our monthly roundup of WordPress news, website inspiration, exclusive deals and interesting articles.
Unsubscribe at any time. We do not spam and will never sell or share your email.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Article By
James LePage
Contributors/Editors
notloggedin
James LePage is the founder of Isotropic, a WordPress education company and digital agency. He is also the founder of CodeWP.ai, a venture backed startup bringing AI to WordPress creators.
We're looking for new authors. Explore Isotropic Jobs.
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram