Giter VIP home page Giter VIP logo

prerender-node's Introduction

Prerender Node Build Status NPM version

Google, Facebook, Twitter, and Bing are constantly trying to view your website... but Google is the only crawler that executes a meaningful amount of JavaScript and Google even admits that they can execute JavaScript weeks after actually crawling. Prerender allows you to serve the full HTML of your website back to Google and other crawlers so that they don't have to execute any JavaScript. Google recommends using Prerender.io to prevent indexation issues on sites with large amounts of JavaScript.

Prerender is perfect for Angular SEO, React SEO, Vue SEO, and any other JavaScript framework.

This middleware intercepts requests to your Node.js website from crawlers, and then makes a call to the (external) Prerender Service to get the static HTML instead of the JavaScript for that page. That HTML is then returned to the crawler.

via npm:

$ npm install prerender-node --save

And when you set up your express app, add:

app.use(require('prerender-node'));

or if you have an account on prerender.io and want to use your token:

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

Note If you're testing locally, you'll need to run the prerender server locally so that it has access to your server.

This middleware is tested with Express3 and Express4, but has no explicit dependency on either.

Testing

The best way to test the prerendered page is to set the User Agent of your browser to Googlebot's user agent and visit your URL directly. If you View Source on that URL, you should see the static HTML version of the page with the <script> tags removed from the page. If you still see <script> tags then that means the middleware isn't set up properly yet.

Note If you're testing locally, you'll need to run the prerender server locally so that it has access to your server.

How it works

  1. The middleware checks to make sure we should show a prerendered page
    1. The middleware checks if the request is from a crawler by checking the user agent string against a default list of crawler user agents
    2. The middleware checks to make sure we aren't requesting a resource (js, css, etc...)
    3. (optional) The middleware checks to make sure the url is in the whitelist
    4. (optional) The middleware checks to make sure the url isn't in the blacklist
  2. The middleware makes a GET request to the prerender service for the page's prerendered HTML
  3. Return that HTML to the crawler from your server

Customization

Whitelist

Whitelist a single url path or multiple url paths. Compares using regex, so be specific when possible. If a whitelist is supplied, only urls containing a whitelist path will be prerendered.

app.use(require('prerender-node').whitelisted('^/search'));
app.use(require('prerender-node').whitelisted(['/search', '/users/.*/profile']));

Blacklist

Blacklist a single url path or multiple url paths. Compares using regex, so be specific when possible. If a blacklist is supplied, all url's will be prerendered except ones containing a blacklist path.

app.use(require('prerender-node').blacklisted('^/search'));
app.use(require('prerender-node').blacklisted(['/search', '/users/.*/profile']));

beforeRender

This method is intended to be used for caching, but could be used to save analytics or anything else you need to do for each crawler request. If you return a string from beforeRender, the middleware will serve that to the crawler (with status 200) instead of making a request to the prerender service. If you return an object the middleware will look for a status and body property (defaulting to 200 and "" respectively) and serve those instead.

app.use(require('prerender-node').set('beforeRender', function(req, done) {
	// do whatever you need to do
	done();
}));

afterRender

This method is intended to be used for caching, but could be used to save analytics or anything else you need to do for each crawler request. This method is called after the prerender service returns HTML.

app.use(require('prerender-node').set('afterRender', function(err, req, prerender_res) {
	// do whatever you need to do
}));

You can also use afterRender to cancel the prerendered response and skip to the next middleware. For example, you may want to implement your own fallback behaviour for when Prerender returns errors or if the HTML is missing expected content. To cancel the render, return an object containing cancelRender: true from afterRender:

app.use(require('prerender-node').set('afterRender', function(err, req, prerender_res) {
	if (err) {
		return { cancelRender: true };
	}
}));

protocol

Option to hard-set the protocol. Useful for sites that are available on both http and https.

app.use(require('prerender-node').set('protocol', 'https'));

host

Option to hard-set the host. Useful for sites that are behind a load balancer or internal reverse proxy. For example, your internal URL looks like http://internal-host.com/ and you might want it to instead send a request to Prerender.io with your real domain in place of internal-host.com.

app.use(require('prerender-node').set('host', 'example.com'));

forwardHeaders

Option to forward headers from request to prerender.

app.use(require('prerender-node').set('forwardHeaders', true));

prerenderServerRequestOptions

Option to add options to the request sent to the prerender server.

app.use(require('prerender-node').set('prerenderServerRequestOptions', {}));

Caching

This express middleware is ready to be used with redis or memcached to return prerendered pages in milliseconds.

When setting up the middleware, you can add a beforeRender function and afterRender function for caching.

Here's an example testing a local redis cache:

$ npm install redis
var redis = require("redis"),
	client = redis.createClient();

prerender.set('beforeRender', function(req, done) {
	client.get(req.url, done);
}).set('afterRender', function(err, req, prerender_res) {
	client.set(req.url, prerender_res.body)
});

or

var redis = require("redis"),
client = redis.createClient(),
cacheableStatusCodes = {200: true, 302: true, 404: true};

prerender.set('beforeRender', function(req, done) {
  client.hmget(req.url, 'body', 'status', function (err, fields) {
    if (err) return done(err);
    done(err, {body: fields[0], status: fields[1]});
  });
}).set('afterRender', function(err, req, prerender_res) {
  // Don't cache responses that might be temporary like 500 or 504.
  if (cacheableStatusCodes[prerender_res.statusCode]) {
    client.hmset(req.url, 'body', prerender_res.body, 'status', prerender_res.statusCode);
  }
});

Using your own prerender service

We host a Prerender server at prerender.io so that you can work on more important things, but if you've deployed the prerender service on your own... set the PRERENDER_SERVICE_URL environment variable so that this middleware points there instead. Otherwise, it will default to the service already deployed by prerender.io.

$ export PRERENDER_SERVICE_URL=<new url>

Or on heroku:

$ heroku config:set PRERENDER_SERVICE_URL=<new url>

As an alternative, you can pass prerenderServiceUrl in the options object during initialization of the middleware

app.use(require('prerender-node').set('prerenderServiceUrl', '<new url>'));

Contributing

We love any contributions! Feel free to create issues, pull requests, or middleware for other languages/frameworks!

License

The MIT License (MIT)

Copyright (c) 2013 Todd Hooper <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

prerender-node's People

Contributors

123nenad avatar alex0007 avatar alexkashkan avatar arunoda avatar blimmer avatar chaselee avatar daguej avatar dgrabla avatar digitalmaster avatar homeyer avatar infomofo avatar jackhsu978 avatar jamesbrill avatar janpot avatar jeroennoten avatar jirikrepl avatar joostschouten avatar lammertw avatar lluczo avatar morrisda avatar nicolashenry avatar poowaa avatar skarap avatar sumerion avatar sunshineo avatar thoop avatar varrocs avatar vetm avatar wejendorp avatar zuzana avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

prerender-node's Issues

zlib.js error for some pages

Hi,
I'm using prerender-node v2.3.0 and the latest prerende.io code from github (https://github.com/prerender/prerender).
In most cases the rendering of my AngularJS application works fine, but in some cases I get the following error displayed in the web browser:

Error: unexpected end of file
at Zlib._handle.onerror (zlib.js:370:17)

This happens, for example for this page:

http://eventregistry.org/event/3339762?_escaped_fragment_=?lang=eng

Even in cases when it does render, when I reload the same page again, it for sure fails, displaying the above error.

Any idea about the reasons for this problem?

Thank you in advance.
Gregor

301 Moved Permanently Loop

I am using CloudFlare's HTTPS only feature. This may have something to do with it. I preform the following HTTPS request:

GET /chrome HTTP/1.1
Content-Type: application/json
Cookie: __cfduid=dd925028c8e4293ff5597f0c9bb17d38b1456509526
Host: google.com
Connection: close

* Host and GET path are replaced here for security reasons.

and I receive a response filled with HTML.

<html>
 <blink>YAY!</blink>
</html>

BUTTTT when I do a request

GET /chrome HTTP/1.1
User-Agent: Twitterbot/1.0
Content-Type: application/json
Cookie: __cfduid=dd925028c8e4293ff5597f0c9bb17d38b1456509526
Host: google.com
Connection: close

I get a response back that looks like

HTTP/1.1 301 Moved Permanently
Server: cloudflare-nginx
Date: Wed, 30 Dec 2015 21:07:06 GMT
Content-Type: text/html;charset=UTF-8
Transfer-Encoding: chunked
Connection: close
X-Powered-By: Express
Cf-Ray: 25d0b45dd24g23ae-IAD
Location: https://google.com/chrome
Set-Cookie: __cfduid=d9ffaae8a4c3bbdc9f04830356133c3191455509626; expires=Thu, 29-Dec-16 21:07:06 GMT; path=/; domain=.google.com; HttpOnly
Via: 1.1 vegur

* Via for heroku
** Cf-ray and Set-Cookie for CloudFlare
*** The 301 redirect is to the same URL??

Any ideas?

504 when accessing Angularjs routes

I've setup an express wrapper for my angularjs app with the prerender-node package.
I cannot access any nested urls, it's constantly returning a 504, without the ?_escaped_fragment bit the app runs as expected.

I've also included #!'s in my urls so that it's easier to debug. Has anyone faced this issue? I've been trying to resolve it since the past week.
Page Url: http://localhost:8080/#!/1/1877
While using Prerender: http://localhost:8080/?escaped_fragment=/1/1877/ - > 504 error

Thanks!

Update to adept to Google's behavior

Ad the README file saya, Prerender adheres to google's _escaped_fragment_ proposal.

However, as far as I can tell, Google has already deprecated that proposal, and stopped
adhering to it.

In practice, this means that simply having <meta name="fragment" content="!"> in the header is no longer sufficient for making GoogleBot add the required query to the URL... which means that currently, GoogleBot is not getting the prerendered version.

To solve this, we would need to add the user agent string of the google bot back to the allowed list.

(Or am I missing something here?)

Support for Google App Engine SSL

We came across an issue when using prerender-node with an SSL site on GAE. GAE passes a header x-appengine-https="on" for SSL requests. Adding:

  if( req.headers['x-appengine-https'] ) {
    protocol = req.headers['x-appengine-https'] === 'on' ? 'https' : 'http';
  }

to the buildApiUrl function seems to fix the issue.

TypeError parsedQuery.hasOwnProperty is not a function

I've recently switched to prerender service to see if it performed better than the self hosted one but I'm getting this;

 TypeError: parsedQuery.hasOwnProperty is not a function
   at Function.prerender.shouldShowPrerenderedPage (/app/node_modules/prerender-node/index.js:132:33)
   at module.exports (/app/node_modules/prerender-node/index.js:6:17)
   at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
   at trim_prefix (/app/node_modules/express/lib/router/index.js:312:13)
   at /app/node_modules/express/lib/router/index.js:280:7
   at Function.process_params (/app/node_modules/express/lib/router/index.js:330:12)
   at next (/app/node_modules/express/lib/router/index.js:271:10)
   at expressInit (/app/node_modules/express/lib/middleware/init.js:33:5)
   at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
   at trim_prefix (/app/node_modules/express/lib/router/index.js:312:13)

app.js

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

Any ideas where I may be going wrong?

Thanks

504 error with Meteor's AppCache package

Using :
appcache
iron:router
prerender-node

If Appcache is active :
I got (sometimes) a 504 error when ask /login?escaped_fragment=
I got a 200 when ask /?escaped_fragment=login

If Appcache is inactive :
I got a 200 when ask /login?escaped_fragment=
I got a 200 when ask /?escaped_fragment=login

I had to revert the url in beforeRender to not have 504 error.

Log :
I20160415-15:10:11.804(2)? afterRender : /login?escaped_fragment= 200
I20160415-15:10:13.488(2)? afterRender : /login?escaped_fragment= 200
I20160415-15:10:24.643(2)? afterRender : /login?escaped_fragment= 504

Any idea ?
POC-APPCACHE.zip

Suggestion for documentation and better error reporting

Hi there,

I've spent some time getting the middleware to work. In the end it appeared that my apache config with virtual hosts caused the problem. Somehow the request hostname is set to the local hostname.

Setting the host name manually solved the problem.

require('prerender-node').set('host', 'my-website.com');

It might be valuable for others to have this in the docs.

It took me quite a while to find out this was the problem. The prerender.io service only responds with; 504 Gateway Time-out. I think the prerender.io service should provide a more detailed response e.g.;

Could not render page at http://localhost:3010/app-path/.

SSLv3

I turned off SSLv3 yesterday. This caused the prerender to break. When I turned SSLv3 back on, Prerender came back up. My assumption is the prerender.io code relies on SSLv3 for https requests.

Any fix/help would be appreciated. Thank you

Redirecting when using https

When i send a request to https://www.closic.com/pt?_escaped_fragment_= the server is redirecting to "/pt".

prerender-5 2016-01-04T01:51:54.111Z getting http://www.closic.com/pt
closic-web-0 2016-01-04T01:51:54.153Z - debug: GET /pt 200 4606 - 0.740 ms
closic-web-0 2016-01-04T01:51:54.162Z - debug: GET /lib/animate.css/animate.min.css 200 55522 - 0.662 ms
closic-web-0 2016-01-04T01:51:54.201Z - debug: GET /pt?_escaped_fragment_= 301 - - 96.384 ms
prerender-5 2016-01-04T01:51:54.202Z got 301 in 91ms for http://www.closic.com/pt
closic-web-0 2016-01-04T01:51:54.236Z - debug: GET /lib/fontawesome/css/font-awesome.min.css 200 26711 - 2.174 ms
closic-web-0 2016-01-04T01:51:54.266Z - debug: GET /lib/intl-tel-input/build/css/intlTelInput.css 200 18418 - 1.923 ms
closic-web-0 2016-01-04T01:51:54.268Z - debug: GET /css/main.css 200 5220 - 3.645 ms
closic-web-0 2016-01-04T01:51:54.270Z - debug: GET /lib/angular-loading-bar/build/loading-bar.min.css 200 2236 - 5.715 ms
closic-web-0 2016-01-04T01:51:54.277Z - debug: GET /css/responsive.css 200 603 - 2.315 ms
closic-web-0 2016-01-04T01:51:54.279Z - debug: GET /css/paper.min.css 200 142634 - 3.211 ms
closic-web-0 2016-01-04T01:51:54.402Z - debug: GET /pt 200 4606 - 0.727 ms

Why this is happening? The log in closic-web shows that /pt?escaped_fragment= are redirecting but i'm not finding the code that redirects. Can be a prerender-node middleware bug?

When i run locally without https its working fine.
I added www.closic.com in /etc/hosts and configured nginx locally too.
(http://www.closic.com/pt?_escaped_fragment_=)

Creating sitemap?

I've been reading on how to make an angularjs app seo friendly and ended up being recommended to use prerender.io and it seems quite interesting on how it works.

Right now, I've added prerender-node via npm to my project and am using the hashbang (#!)

My question is, how do I know for sure that it works? I've tried using Fetch as Google to view and render the website but I see that the ui-view doesn't have anything in it when google fetches it.

I've also tried using third party websites to create a sitemap which only returns the root url without adding all the other routes/states.

I've tested to see with the url instead of being #! using the ?_escaped_fragment_=/ and it returns the website normally so I'm guessing it's implemented correctly?

Also, I can do manually the sitemap, but what is the correct way to do it. Currently I have it like this:

<url>
  <loc>http://example.com/#!/results</loc>
</url>

Documentation is unclear

On your home page @ https://prerender.io/. Below are the steps to use prerender

Run this on the command line

$ npm install prerender-node --save
And when you set up your express app...
app.use(require('prerender-node'));

where am i specifying the external prerender server details ?

Add bitlybot

Hi,

what about bitlybot? We are using bitly to create short links and bitlybot scrap our default title of page.

V.

Laravel integration

Hey,

I created middleware to integrate prerender with the popular PHP-framework Laravel:

https://github.com/JeroenNoten/laravel-prerender

I am planning to add unit tests, support for gzip, and pre- and post- callbacks soon. If you have any suggestions, please let me know.
And feel free to add it to the documentation, if you want.

Use of '&' escaped or not in URL

Hi

I am probably breaking some rule, my angular routes\URL's can sometimes contain '&' .

http://localhost/?_escaped_fragment_=/shop/BMW/3%20SERIES/83-93/E30%203%20SERIES%20320,%20323%20%26%20325/Front%20-%20Brake%20Calipers%20and%20Wheel%20cylinders

decoded
http://localhost/?_escaped_fragment_=/shop/BMW/3 SERIES/83-93/E30 3 SERIES 320, 323 & 325/Front - Brake Calipers and Wheel cylinders

This works fine for AngularJS routing, However when I pass this through prerender-node ( am using a local prerender server). The URL is reformatted, everything after '&' becomes a query parameter.

http://localhost/? 325/Front - Brake Calipers and Wheel cylinders=#!/shop/BMW/3 SERIES/83-93/E30 3 SERIES 320, 323

The page obviously does not render correctly in this case.
Is there anyway to prevent this being rewritten ?
OR do I have to make sure my Angular routes do not have the '&' character in them ?

Regards

Gary

afterRender event not called, why?

I am running a custom prerenderService, which works perfectly fine locally, but once deployed to remote server, the middleware no longer completes the request.

It is unusual because if I hit the remote deployed prerenderService directly using curl, it works fine. However the node.js middleware request isn't getting a response.

The beforeRender event fires fine, however the afterRender events never fires. I am also not able to collect any trace log information. So is there a way to catch the request to see if there was an error somewhere?

Shouldn't buildApiUrl use req.originalUrl inseated of req.url ?

In case you have a middleware that does some url rewrite/alias and overwrites req.url, express keeps a copy of the original url in req.originalUrl.

It would be good if prerender-node used that value instead of req.url.

see https://github.com/prerender/prerender-node/blob/master/index.js#L211

Example :

  • GET /my-nice-angular-app-url?_escaped_fragment_=val
  • Some middleware rewrites it to /some/thing/else?_escaped_fragment_=val
  • prerender should request /my-nice-angular-app-url?_escaped_fragment_=val

Start an "embedded" prerender server

It will be great if there will be an option to automatically run an "embedded" prerender server. Such that it will start automatically on the same server as the node.js/express.js server.

Prerender works as unusual behaviour

Hi,

Thanks for great job but I got still some wiered issue.

When I render my angularjs page using escaped_fragment= or other user agent it gives a very odd behaviour like sometimes its rendered page but most of the time it doesnt.

Please help me I am unable to find issue.

Thanks,
Vijay Barnwal

add Tumblr crawler

Until recently Tumblr's crawler didn't have a user agent identifying it as such. I contacted them about this (see this issue for more detail) and it appears they are now identifying their crawler with this user agent: "Tumblr/14.0.835.186".

I'm not sure if this is a common enough crawler to add to the list but I thought I'd bring it up.

Not rendering based on user agent, only ?_escaped_fragment_=

I've been using prerender-node and only ever tested that it is working by appending ?_escaped_fragment_= to the end of any url. It renders successfully using the query string, however I just tried setting my user agent to googlebot and a variety of others and prerender didn't render the page - I received the unrendered original.

I'm just using `router.use(require('prerender-node'))``.

Is anybody else experiencing this? Am I missing some configuration? Reading the other issues suggests this was how you identified bots in the first place and the query string was an enhancement - now it seems not to be working. Any ideas?

Add Caching

It will be great if a caching layer will be added.
Meaning when cache timeout is set the rendered version will be kept and served for the timeout set.

NPM update?

NPM hasn't been updated in a while. Any change of a new version soon? Thanks!

Does PreRender Work for SEO with Dynamic Express Routes?

Hello I wanted to know if PreRender also works for SEO indexing of dynamic express routes?

For example, In my Express Single Page App written in Backbone (mysite.com), I understand that PreRender allows me to make mysite.com/ and other static routes like mysite.com/about or mysite.com/contact SEO ready and thus indexed/searchable by Google.

But in the case of my app. Each user has their own public profile, example: mysite.com/user/:UserID in which :UserID could be one of thousands of users in my database (think Twitter or Facebook).

A scenario would be someone searching on Google for 'Obama' and one of the search results would be mysite.com/user/Obama. Or how when I type 'prerender-node' on Google search it gives me the this link (https://github.com/prerender/prerender-node) for Github's database.

Does PreRender-Node support this functionality? And if so how to Implement? Thanks.

Make middleware work with Connect

Is there any way or any plans to make this middleware work with Connect, which in turn works with Express? Haven't found a way to use Prerender, in any easy way, as a Connect middleware.

e-commerce seo

Do you familiar, with any huge sites that are using this approach of pre-rendering html? Like Amazon and so on...?

If they does how can they stand the loads of the bots?

Adding xml to ignored extensions

Add xml to "extensionsToIgnore" variable. I am having a specific problem with sitemap, which usually is a .xml file. I am going to work around it using a blacklist, still, .xml doen't usually need to be prerendered.

missing brackets in documentation

Please note in the examples afterRender, beforeRender and protocol you are missing a ')' bracket at the end!

app.use(require('prerender-node').set('beforeRender', function(req, done) {
    // do whatever you need to do
    done();
}) //missin ) bracket here```

Missing Facebot in crawler user agent array

Facebot is missing from the crawlerUserAgent array.

Facebook has three different user agents.

  • facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)
  • facebookexternalhit/1.1

These two are covered by the facebookexternalhit check

And according to docs

As of May 28th, 2014 you may also see a crawler with the following user agent string:

Facebot

Google indexing

I've been using Google Search Console and tried to index website as Google by their platform. Unfortunately, even though I've been using prerender-node the website scraped by Google was the non-javascript version and therefore I believe that prerender-node fails to identify GoogleBots.

https-only compatibility broken

Hi,

As far as I can tell, compatibiliy for HTTPS-only websites was broken in this commit:

2a58a7c#diff-168726dbe96b3ce427e7fedce31bb0bcL203

In my case, restoring the line:

var protocol = req.protocol;

Fixed my issue. Without this line, pre-render was fetching the cached version of the HTTP index - which redirects to the HTTPS index, resulting in javascript/not rendered content being delivered.

Conor

[METEOR] Name is not a string. perhaps the file extension isn't .rjs?

Hello guys !

Thanks for this awesome package, I was able to test it with a local prerender server, but when I try to use it in my meteor app, it throw me the error I put on title, I've simply do that:

this.prerenderio = Npm.require('prerender-node');

Any idea of why I've this issue ?
Thanks

Update Version & Push to NPM

After the critical vulnerability patch, we should bump the version to 1.0.6 and publish to NPM.

Also, it might be a good idea to make use of the release tags in github, too. That way, it's easier to go back in time to see what's changed between revisions.

Error: socket hang up

Hi,
I'm using dfischer:prerenderio package in my meteor app. And when I try to access http://localhost:3000/?_escaped_fragment_= it causes an error:

Error: socket hang up
 at createHangUpError (http.js:1528:15)
 at Socket.socketOnEnd (http.js:1624:23)
 at Socket.g (events.js:180:16)
 at Socket.emit (events.js:117:20)
 at _stream_readable.js:944:16
 at process._tickCallback (node.js:458:13)

What am I doing wrong?
Thanks in advance,
Dmytro

Request v2.34.0 depends on unsafe version of qs

The current package.json depends on request ~2.34.0. This version of request is considered unsafe according to nsp.

In more current versions of request, the qs dependency is upgraded past 1.0, which is when the vulnerability was patched. The request dependency should be upgraded to resolve this vulnerability.

EDIT: Here's a link to the report

afterRender response undefined

Trying to get this working on sailsjs and having an issue with afterRender

    app.use(prerender.set('prerenderServiceUrl', 'http://myprerender.com'));
    app.use(prerender.set('beforeRender', function(req, done) {
      var fullUrl = req.protocol + '://' + req.get('host') + req.url;
      client.get(fullUrl, done);
    }));
    app.use(prerender.set('afterRender', function(err, req, res) {
      console.log(res);
      var fullUrl = req.protocol + '://' + req.get('host') + req.url;
      client.set(fullUrl, res.body)
    }));

but the afterRender response is undefined.

Blank page

I'm trying to get this running on my site and prerender.getPrerenderedPageResponse seems to be receiving the req ok but I'm just getting a blank when adding ?escaped_fragment= to my url.

My site was previously using the .htaccess implementation and worked fine.

Screen capture

Do you guys have a feature that allows to take advantage of the PhantomJS screen capture capabilities?
Would you accept a contribution that will allow to create a screenshot of the pre-rendered endpoints to be displayed as an Open Graph preview or anything else of similar nature?

http://phantomjs.org/screen-capture.html

Waiting until all assets are loaded before taking HTML snapshot

I'm using the self-hosted solution to host a prerender server and use prerender-node to access that server. I'm in the early stages of setting this up and was wanting to know the correct/suggested approach for waiting until everything is ready to render the HTML.

For the JS (Angular), I assume you would use window.prerenderReady = true at some point in your JS code to notify prerender that it's ready, but what about the CSS or images? Currently when I try to ping my website using my prerender server, it's 50/50 whether the correct page will be rendered. Sometimes the page will render like normal, and sometimes it will render with a lot of 404s for the CSS/images on the page.

Obviously that will be terrible for SEO, so what is the recommended approach for handling assets? I would be against doing some kind of timeOut to check if it's loaded as this could affect the time it takes for the googlebot to fetch the page.

503 when prerender service is unavailable

I'm using my own prerender service and would like to return 503 errors when it is unavailable. Right now it's failing silently and just runs the next middleware. Basically it then shows javascript pages to the search engine.

Now I have the following setup to detect when a route has run through the middleware with failed prerendering (app is my express server)

prerender.set('prerenderServiceUrl', config.prerenderServiceUrl);
prerender.set('beforeRender', function (req, done) {
  req.isPrerendered = true;
  done();
});
app.use(prerender);
app.use(function (req, res, next) {
  if (req.isPrerendered) {
    res.send(503);
  } else {
    next();
  }
});

Which is very much a hack. I think it would make sense that the middleware takes care of this or at least makes it easy to configure.

Also, if a bad url (non-existing protocol) is provided in prerenderServiceUrl, the whole app crashes. Maybe it could be handled more gracefully by the service.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.