本文介绍了实施sails.js prerender.io中间件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我有一个角网站上sails.js后台运行。我试图实现prerender.io服务为我的网站,使我的网站可以通过搜索引擎索引。

I have an angular site running on a sails.js backend. I am trying to implement the prerender.io service for my site so that my site can be indexed by search engines.

我遇到的问题是,他们的节点模块安装说明是专为前preSS。基本上,他们希望你设置此中间件:

The problem I am running into is that the setup instructions for their node module are specifically for express. Basically they want you to set up this middleware:

app.use(require('prerender-node').set('prerenderToken', 'r8c9lN6JsUMMfpzYNlht'));

帆不成立的中间件这种方式,而是通过它的政策(在大多数情况下,反正)。

Sails doesn't set up middleware this way, but rather through it's policies (for the most part, anyway).

这个问题被提出但前段时间,现在看来,这只是简单地添加到列表,并从来没有真正解决。

This question was raised some time ago here, however it seems it was simply added to a list and never actually addressed.

我也看了这样的:<一href=\"http://stackoverflow.com/questions/18548850/how-to-use-custom-route-middleware-with-sails-js-ex$p$pssjs\">How使用自定义的路由中间件Sails.js? (防爆pressJS)

和试图实施customMiddleware的解决方案,但都无济于事。

and have attempted implementing the customMiddleware solution, but to no avail.

任何想法如何在船帆设置?

Any ideas how to set this up in sails?

推荐答案

如果你看一下这个问题:的

If you look at this issue: https://github.com/prerender/prerender/issues/12

@ talss89能得到它的工作使用配置/ http.js

@talss89 was able to get it working using config/http.js:

module.exports.http = {
    middleware: {

     prerender: require('prerender-node').set('prerenderToken', 'YOUR_TOKEN'),
     order: [
       'startRequestTimer',
       'cookieParser',
       'session',
       'myRequestLogger',
       'bodyParser',
       'handleBodyParserError',
       'prerender',
       'compress',
       'methodOverride',
       'poweredBy',
       '$custom',
       'router',
       'www',
       'favicon',
       '404',
       '500'
     ]
  }
};

这篇关于实施sails.js prerender.io中间件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 15:57