在localhost上为meteor.js设置prerender.io

1)我已经安装并运行应用程序meteor.js https://github.com/meteor/simple-todos-react

2)我在应用程序目录附近安装了prerender服务器:

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

并设置端口:

 export PORT=3050 

最终运行

 node server.js 

3)我已经安装了模块prerender-node

 meteor npm install prerender-node --save 

设置环境variables:

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

4)我写在./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); }); 

但是当我去链接view-source:http://localhost:3000/?_escaped_fragment_=我没有看到呈现的html

我看到一个错误:

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

我究竟做错了什么?

Solutions Collecting From Web of "在localhost上为meteor.js设置prerender.io"

获得的configuration选项:

  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); }); 
 import prerenderio from 'prerender-node'; Meteor.startup(() => { const settings = Meteor.settings.PrerenderIO; if (settings && settings.token && settings.protocol) { prerenderio.set('prerenderToken', settings.token); prerenderio.set('protocol', settings.protocol); prerenderio.set('forwardHeaders', true); prerenderio.set('afterRender', function afterRender(error) { if (error) { console.log('prerenderio error', error); // eslint-disable-line no-console return; } }); WebApp.rawConnectHandlers.use(prerenderio); } }); 

settings.json

 { "PrerenderIO": { "token": "xxxxxxxxxxxxxx", "protocol": "http" //https }, }