0

This is a follow up question to the one found here: CloudFront + S3 Website: "The specified key does not exist" when an implicit index document should be displayed

I am trying to host a React single page app (static website) through S3 and I want to allow https access only (using a custom SSL). I have everything configured with CloudFront and my website is showing up at the CloudFront URL just fine. But when I navigate around the app, I get the error shown in the link above.

According to that post, the error is fixed by switching from a REST to a website endpoint. But in the process, you have to make your S3 bucket public. My question: is there a way to fix this error without switching to a website endpoint and, in the process, making all my S3 content public? Is there some kind of workaround within the AWS ecosystem where I can combine private S3 contents with a process that returns the html doc without the XML formatted error? According to this reference (https://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteEndpoints.html#WebsiteRestEndpointDiff), this seems like it may not be possible, but I'm hoping someone can prove me wrong.

Thanks!

Trey
  • 1

1 Answers1

0

The error you're getting usually occurs when your application tries to access something which it isn't privileged to.

Since you mentioned the app loads normally but you get this error while you move around; So it can be the case that it occurs when a component tries to load a private resource which you haven't added in the policies you have defined.

My question: is there a way to fix this error without switching to a website endpoint and, in the process, making all my S3 content public?

Definitely! But you need to pin point the resources which is being accessed when you're getting the error! I would request you to provide more info regarding the same.

Lastly, if you switch to website endpoints, you won't to able to serve private S3 content. You'll have to make it all public. You can find more info about this here: https://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteEndpoints.html#WebsiteRestEndpointDiff

Manu Sharma
  • 656
  • 1
  • 7
  • 22
  • just to be sure, you have set the error page in the S3 bucket's static website hosting config as index.html only, right? – Manu Sharma Jun 04 '20 at 07:24