1
Hello, in my main code of my app, with the use of express, I’m trying to remove the "x-powered-by" header, and I’ve used so much
app.disable("x-powered-by")
how much
app.set("x-powered-by", false)
Besides, I’ve tried using the Helmet module .
But, no way comes into effect and the header continues to appear in the requests.
Follow the structure of my code:
const express = require('express'),
app = express(),
http = require('http'),
cors = require('cors'),
helmet = require('helmet'),
app.set('x-powered-by', false);
...
app.use(cors());
app.use(helmet());
...
http
.createServer(app)
.listen(port, () => {
console.log(`running in port ${port}`);
});
Have you tested with Helmet using
hidePoweredBy
andsetTo: 'outra coisa'
? Works well for me...– Sergio
@Sergio, already, but still continues showing the "Express".
– Samir Braga
Samir, take a look here: https://ide.c9.io/sergiocrisostomo/sopt-218873, you can see the header?
– Sergio
@Sergio, you could be in charge of someone else who doesn’t need this signup?
– Samir Braga
Yes, this one you can see without signup here: https://sopt-218873-sergiocrisostomo.c9users.io/ Click on "open app"
– Sergio
@Sergio, the answer in the header has "x-powered-by: Renewable Energies, love and good music"
– Samir Braga
Exact :) You can switch to an empty string.
– Sergio
The currently running code is https://jsfiddle.net/waqt6z3L/
– Sergio
@Sergio, in his own way, locally it wasn’t working, but when going up to the host, it worked. You can put it as a response if you like. Thank you! :)
– Samir Braga