Prerender.io middleware implementation in sails.js file
I have an angular site running on the sails.js backend. I am trying to implement a prerender.io service for my site so that the site can be indexed by search engines.
The problem I am facing is that the installation instructions for their node module are specifically meant to be expressed. They basically want you to install this middleware:
app.use(require('prerender-node').set('prerenderToken', 'r8c9lN6JsUMMfpzYNlht'));
Sail not establish middleware thus, through it policies
(for the most part, in any case).
This question was raised a while ago here , however it seems like it was just added to the list and was never addressed.
I also looked at this: How do I use my own route middleware with Sails.js? (ExpressJS)
and tried to implement customMiddleware solution but to no avail.
Any ideas how to set this in sails?
source to share
If you look at this issue: https://github.com/prerender/prerender/issues/12
@ talss89 was able to get it to work with 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'
]
}
};
source to share