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


设置环境变量:

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


我究竟做错了什么?

最佳答案

获得的配置选项:

    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);
   });

关于javascript - 在localhost上为meteor.js设置prerender.io,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40792256/

10-13 00:45