Ad

Prerender Angular2 Pages As Pure HTML

- 1 answer

My problem is that facebook and twitter bots do not execute javascript, and I need metatags in my items, so that the right image/title/message is displayed when sharing on those platforms.

I have a nginx server serving angular2 content as static files.

Now I want to somehow prerender the pages for those bots. More specifically, I want to redirect the bots to an instance of for example phantomJS which would prerender the pages. I want that instance to run as a separate service on a different IP so that I can perhaps re-use it for something else too.

I have no idea where and how to start. Are there any nodejs server packages, who would already know how to do that for me?

Ad

Answer

Ended up installing a self-hosted version of prerender (https://github.com/prerender/prerender) and routed the bots to it through nginx. Works great!

Ad
source: stackoverflow.com
Ad