amazon-s3cloudflare

S3 hosted website with Cloudflare returns 404 status code for any route


I have an S3 hosted website working well behind Cloudflare with the following:

ss1

example.com/ works fine

example.com/test also works but the document itself in the network tab is returning 404, naturally, because /test doesn't exist on S3.

This is a problem for SEO, how do I configure Cloudflare to treat 404s as 200s?

In Cloudfront I usually do this:

ss2

But I can find no corresponding configuration in Cloudflare. Will this have to be done in a Cloudflare worker? What did people do before Workers existed?


Solution

  • This is what I did to fix the issue:

    Go to => Your S3 Bucket > Properties > Static website hosting

    under the Error document input, I added the index.html enter image description here

    it is still showing the error in the browser console, however the 404 is gone and the site works

    the bad news is that in cloudflare I had to stick to "Flexible" enter image description here

    My Settings React with Standard Route setup enter image description here