Any guide for prerender-node and your own server on Meteor?

Hi all,

I’m looking at prerender.io to better crawl my app. However, how do you use prerender-node (the NPM package) on a meteor application? The docs are for express (app.require) and I’m not 100% sure what the meteor alternative to that is or where to put it in my app.

Any help would be greatly appreciated as always :slight_smile:

Cheers,

Tom.

+1
not sure how to make that happen too.

Meteor guide still suggest using dfishers package. But I think the better choice is to user the npm package.

Documented here? http://guide.meteor.com/deployment.html#seo

the docs are suggesting to use the atmosphere package.
The question here is for the npm package.

1 Like

Anyone figured it out?

Been away for a while so apologies for the lack of a response. I actually found using the NPM package worked better than the Atmosphere package… for some reason. I don’t know why but the Atmosphere package wouldn’t send the pages through to prerender!

Unforunately, I have since removed that project so I can’t help with the setup. I may have a backup somewhere though so I’ll have a look on my other machine later.

I found this way:

  1. remove spiderable package and similar
  2. meteor npm install prerender-node --save
  3. place code here: “server/prerenderio.js”
// Use Prerender with your token
var prerenderio = Npm.require('prerender-node').set('prerenderToken', 'YOUR_TOKEN'); 
// Feed it to middleware! (app.use)
WebApp.connectHandlers.use(prerenderio);

You may try using this package, it is working for me:

1 Like

That works for me:

import prerenderIO  from 'prerender-node';
var settings = Meteor.settings.PrerenderIO;

Meteor.startup(() => {
	if (!__meteor_runtime_config__.ROOT_URL.match(/www|stg|app/)) return;
  prerenderIO.set('prerenderToken', settings.token);

	prerenderIO.set('beforeRender', function(req, done) {
		console.log('\nprerender before', req.headers, '\n\n');
		done();
	});
	
  prerenderIO.set('afterRender', function afterRender(err, req, prerender_res) {
    if (err) {
      console.log('prerenderio error', err); 
      return;
    }
		console.log('prerender after', req.url, '\nheaders:', req.headers, '\nres complete:', prerender_res.complete, prerender_res.statusCode, prerender_res.statusMessage	, '\nres headers:', prerender_res.headers, '\nres body', prerender_res);
  });

  WebApp.rawConnectHandlers.use(prerenderIO);
	
	console.log('\nprerender service:', settings);
});
2 Likes

I currently use the chrome-version of prerenderer: https://github.com/bosondata/chrome-prerender/

which seems to work nicely and has similar (but limited) api as prerender.io, so you can use any existing middleware.

I use nginx config for prerender, because the node-version did not work very well (i had inifinte loops, because it did not remove ?escaped_fragment= )

Hi, I have recently implemented prerender-node and my own Node prerender server with EC2, for Meteor. If you’re looking for something similar, please let me know.

Please post more about it. Thanks!