Yes, it is quite possible.
You need to disable the Sails middleware called poweredBy , and tell Express.js not to add its own header.
Just update the config/http.js configuration file so that it looks like this:
module.exports.http = { middleware: { disablePoweredBy: function(request, response, next) { var expressApp = sails.hooks.http.app; expressApp.disable('x-powered-by'); // response.set('X-Powered-By', 'One Thousand Hamsters'); next(); }, order: [ // ... // 'poweredBy', 'disablePoweredBy', // ... ] } };
Here we extract an instance of the Express application from the Sails hooks and then disable() it to set the x-powered-by configuration parameter to false . This will prevent the header from appearing.
And to enable this custom middleware, you need to add it to the order array. You can simply replace poweredBy middleware with disablePoweredBy .
In addition, without commenting on the response.set() method, you can set your own header value.
Slava Fomin II
source share