CORS failure in one of my buckets while all policies and settings are identical.

0

I'm struggling with identifying a CORS problem. I have three buckets, one of which contains PNGs that I want to allow users to download via my app. I've tried pretty much everything, but I continue to have the following issue: "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."

When I use one of my other buckets that have the exact same bucket policy (allowing for CORS), it works without error. What am I doing wrong? Where should I look?

Thanks.

2개 답변
1
수락된 답변

I would suggest looking at your other "good buckets" and see what permissions they have. Do they have a policy added that allows a service to access objects in the bucket? Use an IDE to color code the policies and open up a split browser to see them side by side. For testing purposes, you might use the AWS policy generator to help set up a very permissive policy that allows all services to access objects in your bucket. Once you get access, then tighten up the policy and allow-list the specific resource access to your buckets and objects. Also, are all of these buckets in the same account? You might look at your IAM policies to make sure they are the same, if you are using another account.

AWS
전문가
답변함 3달 전
profile picture
전문가
검토됨 한 달 전
  • yeah I did that and all is 100% identical. After long search the only solution i found was to change the metadata of each png to cache-control: no-cache. Super strange the other buckets don't have this need

  • Regarding the IAM policies and different accounts, can you elaborate? I have all three buckets visible in my accounts and open publicly

  • Hi LW's, I was just brainstorming on things that you could look to for clues. A standard of practice among some is to have a Dev, Test, and Production account - each for a different purpose. I was just suggesting that if you have multiple accounts, to look at your other accounts and compare permissions.

    On another topic, have you thought about adding a CloudFront distribution to your S3 buckets to securely serve your content to users? You could keep your buckets closed to the public, but allow CloudFront to access objects in your bucket. Read up on it and see what you think?

    https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-restricting-access-to-s3.html

1

Hi,

It looks like the CORS settings in the bucket with PNGs are not allowing requests from other origins. Even though the bucket policies are the same, there could be variations in the CORS settings. Take a look at the CORS settings of the problematic bucket and make sure the 'Access-Control-Allow-Origin' header is set correctly. You can find more information in the official documentation https://docs.aws.amazon.com/AmazonS3/latest/userguide/cors.html

profile picture
답변함 3달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠