TIMEX TIMEX - 1 year ago 66
Javascript Question

In Node.js/Express, how do I automatically add this header to every "render" response?

I have many of these "controllers":

var stuff = { 'title': 'blah' };

Notice res.render? I want to add this header to every response header I make:

X-XSS-Protection: 0

How can I add that response header automatically?

Answer Source
// global controller
    res.header('X-XSS-Protection' , 0 );
    next(); // http://expressjs.com/guide.html#passing-route control

Just make sure this is the first controller you add, order is significant.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download