Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access image from aws result in a CORS error #80

Open
pepeloper opened this issue Jul 23, 2020 · 2 comments
Open

Access image from aws result in a CORS error #80

pepeloper opened this issue Jul 23, 2020 · 2 comments

Comments

@pepeloper
Copy link

👋 Hey! I've been getting a cors error when try to load a imagen from aws. I found a related issue with a proper solution on the croppie library itself Foliotek/Croppie#516 but I don't know how to make it fit here.

If we can find out any workaround I will try to help with a PR

@jofftiquez
Copy link
Owner

Hello @pepeloper thanks for the issue. I'll look into this, no promises tho. I've been super busy with work lately. I'd appreciate if you could come up with a PR. Thank you so much! Stay safe.

@roenfeldt
Copy link

roenfeldt commented Jan 15, 2021

In case anybody needs a solution to this problem: it's not related to the library, but rather to how AWS is handling the incoming HTTP requests to the stored images. You need to set up the CORS policy at the bucket level on your AWS S3 Management Console. Choose your bucket, click the Permissions tab, and then scroll all the way down to the Cross-origin resource sharing (CORS) panel.

In there, click the Edit button to the right, and create your JSON configuration. Here's an example of how I'm handling such a scenario. YMMV

[ { "AllowedHeaders": [ "*" ], "AllowedMethods": [ "GET", "PUT", "POST", "DELETE" ], "AllowedOrigins": [ "http://dev.test", "https://example.com" ], "ExposeHeaders": [] }, { "AllowedHeaders": [ "*" ], "AllowedMethods": [ "GET" ], "AllowedOrigins": [ "http://dev.test", "https://example.com", "https://www.example.com" ], "ExposeHeaders": [] } ]

It should go without saying, but I'll point it out nevertheless. This won't work unless your bucket has public access enabled.

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants