Search code examples
amazon-s3seocdnsingle-page-applicationamazon-cloudfront

Single Page App + Amazon S3 + Amazon CloudFront + Prerender.io - how to set up?


  1. I have single page app built with Backbone.js.
  2. I host app (app consists of static files only) on Amazon S3.
  3. I use CloudFront as a Bucket CDN.
  4. App is accessed by https://myapp.com -> https://abcdefgh34545.cloudfront.com -> https://myBucket.s3-eu-west-1.amazonaws.com/index.html

How I can use Prerender.io service with this stack? I have to somehow detect that WebSpider/WebRobot is accessing the page and redirect it to prerender.io...


Solution

  • It's hard to use Prerender.io with a static Amazon S3 site.

    You could stand up an nginx/apache server in front of s3: https://myapp.com -> https://mynginx-server.com -> https://myBucket.s3-eu-west-1.amazonaws.com/index.html

    This solution is less ideal because you lose the closest-location benefit of cloudfront.

    This is a good article about a custom solution: http://www.dave.cx/post/23/prerendering-angular-s3/

    David was able to generate the static HTML and save them in S3, then use CloudFlare to detect _escaped_fragment_ in the URL and redirect it to the static HTML on S3.