Ad

Settings Prerender.io For Meteor.js On Localhost

1) I have installed and ran the application meteor.jshttps://github.com/meteor/simple-todos-react

2) I have installed prerender server near to the application directory:

git clone https://github.com/prerender/prerender.git
cd prerender
npm install

and set port:

export PORT=3050

end run

node server.js

3) I have installed module prerender-node:

meteor npm install prerender-node --save

Set the environment variables:

export PRERENDER_SERVICE_URL="http://localhost:3050/"

4) And I wrote in ./server/main.js:

import { Meteor } from 'meteor/meteor';
import { WebApp } from 'meteor/webapp';
import prerenderIO from 'prerender-node';

Meteor.startup(() => {
  prerenderIO.set('host', 'localhost');
  prerenderIO.set('protocol', 'http');
  prerenderIO.set('port', '3000');
  WebApp.connectHandlers.use(prerenderIO);
});

But when I go to the link view-source:http://localhost:3000/?_escaped_fragment_= I do not see the rendered html.

I see an error:

GET http://localhost:3000/?_escaped_fragment_= 504 

What am I doing wrong?

Ad

Answer

Earned configuration option:

    import { WebApp } from 'meteor/webapp';
    import { Meteor } from 'meteor/meteor';
    import prerenderio from 'prerender-node';

    Meteor.startup(() => {
      prerenderio.set('host', 'localhost:3000');
      prerenderio.set('protocol', 'http');
      prerenderio.set('forwardHeaders', true);
      prerenderio.set('afterRender', function afterRender(error) {
          if (error) {
             console.log('prerenderio error', error);
             return;
          }
     });
     WebApp.rawConnectHandlers.use(prerenderio); 
   });
Ad
source: stackoverflow.com
Ad