13

I have a React app that runs on AWS S3 and CloudFront. When I access the app from the given URL it opens the home page fine. When I navigate to another page using a button on the nav bar it opens the page just fine. But if I then refresh the page I get this error:

enter image description here I also get that same error if I attempt to navigate to the page via a specific path such as www.website.com/blog.

If I access the website straight from the S3 object URL everything works just fine. Pages reload and I can use direct paths to open a page. This leads me to believe the issue lies in CloudFront. However I have no idea where to start in debugging that issue.

S3 setup: enter image description here

Max Phillips
  • 6,991
  • 9
  • 44
  • 71
  • I have the same problem. Did you find a solution? – Vinicius Santana Sep 11 '17 at 02:18
  • Yeah, this thread... https://stackoverflow.com/questions/34060394/cloudfront-s3-website-the-specified-key-does-not-exist-when-an-implicit-ind – Max Phillips Sep 11 '17 at 14:53
  • I have faced same issue and index.html file was not found. Reason: because I have created a directory under root directory of s3 bucket and index files was placed under this.The solution for me was deleted additional directory and placed index file under root. Another solution is you have to map Origin Path under Cloud front if you want to keep your custom directory inside root object. – Sudhanshu Shekhar Sep 06 '19 at 10:15
  • 6
    The solution is go to Cloud front -> Select you cloud distribution detail -> select tab General -> Select edit -> In this form Setup the property Default Root Object to index.html – shontauro Nov 19 '19 at 18:36
  • Root Object means: The object that you want CloudFront to return (for example, index.html) when a viewer request points to your root URL (http://www.example.com) instead of to a specific object in your distribution (http://www.example.com/index.html). – shontauro Nov 19 '19 at 18:36

1 Answers1

5

You have to set the S3 index url and S3 error url to your index page..try it

Janier
  • 3,982
  • 9
  • 43
  • 96