Wrapper around third-party Prerender.io package.
Makes use of the built-in SEO support in Galaxy. If your app qualifies for SEO support, run:
meteor add mdg:seo
to turn on the built-in Prerender.io integration. You may also use this package with non-Galaxy deployments if you configure it manually.
This package is a thin wrapper around the prerender-node
npm module, which understands the configuration format used by Meteor Cloud (Galaxy) to provide apps with a complimentary Prerender.io account. If you're not deploying to Meteor Cloud (Galaxy), you may want to just use the npm module directly.
In your settings.json file, include:
{
"PrerenderIO": {
# Required
"token": "yourtoken" # You need to provide anything here for local server support
# Optional
"serviceUrl": "http://localhost:3033/",
"forwardHeaders": true,
"serverRequestOptions": {},
"allowList": ["^/(\\?.+)?$", "/dashboard"],
"blockList": ["^/search"],
}
}
The serviceURL
is optional and only used to test the Prerender server locally.
Leave it out in your production configuration.
See Prerender-node customization for more details about options.
NOTICE: You may also provide the above settings using environment variables:
PRERENDERIO_TOKEN
PRERENDERIO_SERVICE_URL="http://localhost:3033/"
PRERENDERIO_FORWARD_HEADERS="true"
PRERENDERIO_SERVER_REQUEST_OPTIONS="{}"
PRERENDERIO_ALLOW_LIST="[]"
PRERENDERIO_BLOCK_LIST="[]"
They precede the configuration from the settings file.
There are two options to test whether Prerender is working or not.
serviceUrl
to http://localhost:3033/
.$ PORT=3033 node server.js
?_escaped_fragment_=
, e.g. http://localhost:3000/?escaped_fragment= (perhaps using curl instead of a browser)This will show you the version Prerender generated and search engines will see. You can view logs in the running prerender server which is quite helpful.
serviceUrl
to http://service.prerender.io/
.?_escaped_fragment_=
, e.g. http://localhost:3000/?escaped_fragment=
For more options, take a look at the prerender-node package.
Sometimes the content will not show up immediately and all Prerender sees are loading spinners. This happens because Prerender uses the HTML too early, while the subscriptions are still loading.
Set window.prerenderReady = false;
in the client side code. This will tell Prerender to wait.
When your content is loaded, set it to true
and Prerender will use that version.
It's also possible to never set it to true
.
The request will then time out after about 20 seconds and Prerender will use whatever is on the screen.
Error: connect ECONNREFUSED
at errnoException (net.js:905:11)
at Object.afterConnect [as oncomplete] (net.js:896:19)
If you get this error, you probably forgot to run your local Prerender server.
Thanks to @dferber90 for the [dferber:prerender] package which this is based on. Thanks to @electricjesus and @dfischer for a previous version. Thanks to @arunoda for simplifying prerender-node.