Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Fetch as Google" doesn't load React routes on S3 with CloudFront

I have a react-router site on Amazon S3, with 404 redirects set to hit index.html, where they find the code they need and the site does what it should.

In Google Webmaster Tools, "Fetch as Google" for one of the routes gave error status: Not Found.

I set up Cloudfront for that origin with a Custom Error Response (404 to 200, with Response Page Path /index.html).

But "Fetch as Google" for one of the routes still shows error status: Not Found.

In Chrome or with curl, when I load http://[bucketname].s3-website-us-west-2.amazonaws.com/list/listname/username I see a 404 but the page then loads as expected.

But when I load http://[randomchars].cloudfront.net/list/listname/username I see a 200 with no re-direct and the page loads as expected.

I've submitted a sitemap with the relevant URLs I'd like indexed and asked Google to crawl the site. It hasn't been crawled yet, but my best hope right now are a couple of suggestions I've seen that "Fetch as Google" won't follow redirects, while Googlebot will when it actually crawls the site. I hope this is the case, but if I've missed any other obvious thing, I'd love to know. Thanks in advance!

like image 902
Jami Avatar asked Mar 23 '17 19:03

Jami


1 Answers

I found setting cloudfront with the response page path as "/" worked for me! I was stuck with the exact same problem.

like image 72
mikeg542 Avatar answered Oct 06 '22 00:10

mikeg542