SPA — Prerender.io — AWS S3 How to make it work.
So this post if for all you folks who want to use the goodness that Prerender affords you with AWS’s amazing S3 service in your Single page Application(SPA). The problem is that S3 doesn’t provide any kind of conditional logic which is required to setup prerender. I was struggling with this problem while working with SEATRR and stumbled upon a workable solution.
So let’s break it down into what we need to implement prerender.io
- Setup prerender on a server (in my case an EC2 instance) or get an account at prerender.io to use their service.prerender.io end point.
- A way to identify the user agent.
- Redirect to the Prerender instance.
Step 1 I think most of you have down!
Step 2&3 is where the problem is.
Just remember, You’ll have to enable CORS on your S3 bucket to allow loading these resources. Hope this saves you from going bald early like me.. Cheerio!