Implement middleware in more frameworks/languages #12

thoop opened this Issue Oct 12, 2013 · 65 comments


None yet

thoop commented Oct 12, 2013 edited

I'll keep this list updated as more middleware is added.

Feel free to implement one of the frameworks that people are asking for!

Add a comment if you'd like to see more middleware in another language/framework, and I'll add it to the list!

It's also possible to use the prerender service as a proxy with Nginx.

Edit - the configuration is now in this Gist:

This config will serve existing files directly and use index.html for any other URLs (hash bang, push state, etc). A prerendered page is shown for the list of user agents or by manually appending the query string ?prerender=1 to the URL.


stumpyfr commented Oct 15, 2013

nice solution :)


thoop commented Oct 15, 2013

@Stanback Awesome! Will you make a public gist of that? That way people can fork/edit/share it.

Can you also make it point to and can you check the query string for the key _escaped_fragment_? That way it will work out of the box for people.

Once you do, let me know and I'll add it to and the list of middleware.

Thanks a ton!


thoop commented Oct 16, 2013

I updated this issue and with Nginx. Thanks @Stanback!

runxc1 commented Oct 16, 2013

Anyone started on mvc?


thoop commented Oct 16, 2013

@runxc1 nope! I'll add it to the list above.

Prerender for java framrwork[].
It use java filter to implement. How to use it , please see the demo project on this repo.



thoop commented Oct 16, 2013

@greengerong Nice work! I'll add it to the website and readme tonight.

@thoop Thanks. Are there some one to write ASP.NET MVC client side? I think prerender is a great work. Because I like angular/ko stuff. If not one to write for ASP.NET MVC, I can write it.


thoop commented Oct 16, 2013

@runxc1, were you going to write the ASP.NET MVC one? Or were you just requesting it?

Just want to signal some typo: its Yeoman and not Yeomon :)


thoop commented Oct 21, 2013

@borisrorsvort Oops! Thanks for that.

runxc1 commented Oct 21, 2013

I was more requesting it/seeing if there was one. I won't be able to get around to writing one for a few weeks.


thoop commented Oct 21, 2013

Cool, thanks! @greengerong feel free to write an ASP .NET MVC one :)

@thoop thanks, I will finish it when i am free.

@thoop Prerender for mvc 4.0 . It almost done, I will clean some config and "read me", at next work.



thoop commented Oct 24, 2013

@greengerong Nice! I'll add it tonight. Thanks!


ysimonson commented Oct 24, 2013

Here's a python decorator to get prerender working on tornado:

We're using it in production, although there might be bugs from e.g. missing imports since I plucked out the code.

@thoop Thanks


thoop commented Oct 24, 2013

@ysimonson Awesome! I'll add that one tonight too. Thanks!

thoop referenced this issue Dec 22, 2013


Sails.js support. #35


ysimonson commented Jan 9, 2014

@thoop heads-up, the tornado link goes to the wrong place


thoop commented Jan 9, 2014

Sorry, copy/paste fail. Fixed!

Thanks for letting me know.

Any workaround for sails.js?


thoop commented Mar 29, 2014

@think-teva check out this StackOverflow answer:

The prerender-node middleware is built for ExpressJS (which sails.js uses) so it should be very close to being compatible.

Or check out the bottom of this doc for how they set up passport in sails.js:


thoop commented Apr 17, 2014

@Jarlakxen Great! Thanks a lot. I added it to this card and I'll add it to our website and prerender repo asap.

Hello, I wrote a very simple middleware for the Slim PHP Framework ( ). I use pushState urls and not hash fragments, so the code for the escaped fragments could be wrong, didn't know how to check it. It correctly checks for bots using the user agent, and forwards those requests to Prerender.



thoop commented Apr 21, 2014

Thanks @mahonrig !

Yeah, it looks like it might not work for the hashbang. Check the source from zfr-prerender here for a great php implementation.

Let me know once you get that worked out.

@thoop Thanks for the link! I went back through, did some refactoring, added a bunch of ignored extensions (got them from your apache .htaccess). Works very well for my implementation at the least. It's still a lot simpler then the middleware for the larger frameworks, but Slim is supposed to be :)


thoop commented Apr 21, 2014

@mahonrig great! I'll look at it tonight.


thoop commented Apr 21, 2014

hey @ysimonson , looks like tornadogists let their domain expire:

Do you have that middleware code anywhere else so I can update the link? Thanks!


jeroennoten commented Aug 10, 2014

I created support for Laravel:
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.


thoop commented Aug 10, 2014

Thanks @jeroennoten!

Couldn't find a prerender hapi plugin, so ended up writing one:

Feedback is welcome ;-)

Thanks for the awesome work!


thoop commented Sep 6, 2014

@lupomontero You're awesome! Thanks so much. I'll add it there and to the website

@thoop Nice one!

Anything about IIS and Azure Websites integration ? Thanks Tim

talss89 commented Nov 17, 2014

@ronenteva - I have Sails 0.10 / Prerender working.

Here's my config/http.js file

module.exports.http = {
    middleware: {

     prerender: require('prerender-node'),
     order: [

thoop commented Nov 17, 2014

@talss89 nice! so prerender-node works with sails.js just fine then?

talss89 commented Nov 17, 2014

It certainly seems that way - we've only had it set up for a couple of hours on a dev instance. Google Webmaster Tools seems happy scraping our Angular / Sails / Prerender app though!

@talss89 Thanks,
I ended up adding a config/prerender.js file:

var locals = require('./local');

module.exports = {
    http: {
        customMiddleware: function (app) {
            app.use(require('prerender-node').set('prerenderToken', locals.prerenderio.token));

heston commented Dec 11, 2014

Has anyone seen (or created) a middleware that works with Flask?


tampajohn commented Mar 3, 2015

Thanks for the awesome work, I went ahead and created a golang middleware, feedback is welcome :).

sylido commented Mar 16, 2015

Could we add IIS to the list ? Should be a simple rewrite from Apache ?

tjwebb commented Mar 30, 2015

@talss89 Hey would you be interested in publishing a sails.js hook that integrates with prerender? We love to give shoutouts to community projects. Let me know, thanks.

-- sails.js team

jrapolu commented Nov 17, 2015

Has anyone seen (or created) a middleware that works with Web API & IIS?


thoop commented Nov 20, 2015

Some people have had success using this config with IIS:

jrapolu commented Dec 3, 2015

What are the steps to have own Prerender Server on Azure. My application is written in AngularJS, Web API and deployed in Azure.

luisbox commented Dec 5, 2015

VERY difficult to get working in azure. It's ridiculous. Has anyone else been able to come up with anything better other than the link @thoop provided?

luisbox commented Dec 5, 2015

Okay, after trying a bunch of the code snippets with from the link @thoop originally provided, The last two comments is what worked. You should be able to do the same @jrapolu.

jrapolu commented Dec 5, 2015

Thanks @luisbox. My working with in Azure. But I want to have my own prerender server deployed in azure. So that I can use for my website.

luisbox commented Dec 6, 2015

@jrapolu You can probably accomplish this using an Azure worker role (cloud service). I'd assume that once you set PhantomJS up within an azure worker role, you could use a similar web.config file and point to that service url, instead of Keep in mind that azure websites and web jobs can't run GDI+ which PhantomJS uses.

jrapolu commented Dec 9, 2015

Thanks @luisbox for the info. I have tried with Azure worker role (cloud service). But No luck. Any working sample or steps to be followed will be very helpful.


thoop commented Dec 10, 2015

Please keep discussion on this thread to middleware implementations. Create a new issue if you'd like to discuss running the Prerender server on Azure. Thanks!

jrapolu commented Dec 10, 2015

Sure. Thank you.

Sent from my iPhone

On Dec 9, 2015, at 8:42 PM, Todd Hooper wrote:

Please keep discussion on this thread to middleware implementations. Create a new issue if you'd like to discuss running the Prerender server on Azure. Thanks!

Reply to this email directly or view it on GitHub.

Ruby (Sinatra) and Ruby (Padrino) would be nice. I'll try with the Apache one now as the app is already using that in front of the framework itself anyway.


thoop commented Dec 23, 2015

@emanuil-tolev Does Sinatra or Padrino use Rack middleware? That's what our gem uses so it should be interchangeable if things are set up correctly on our end.

If there is a demand, I can create one for Phoenix (Elixir). Let me know.


thoop commented Feb 16, 2016

@sivsushruth Thanks! I haven't heard of any demand yet for that framework.

vizo commented Mar 11, 2016

@sivsushruth yes please .... 👍

Does Sinatra or Padrino use Rack middleware?

Yep, it uses Rack.

That's what our gem uses so it should be interchangeable if things are set up correctly on our end.

Excellent, though we've gone for the generic Apache one for now.

@SAGV SAGV added a commit to goabout/prerender that referenced this issue Nov 27, 2016

@SAGV SAGV Merge pull request #12 from goabout/fix/
Fix for

iamcz commented Jan 10, 2017

@sivsushruth was elixir/Phoenix support ever added?

Is there a document about

I want to implement a custom middle-ware for a framework but it is not easy to understand how to send request to


thoop commented Apr 20, 2017

@mostafabarmshory the Prerender service API is pretty simple. Here's a short nginx config showing the basics:

The prerender-node middleware should be pretty easy to follow through the code to see the other features we built into that middleware... like whitelisting, etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment