I've gone through every question and blog I can find on the topic, but I can't get rid of x-powered-by: express.
Here's my app which has the sole function of not displaying the "x-powered-by: express" header, combining every bit of advice I've been able to find on how to do this. I've tried each one individually, but none have an effect:
"use strict";
var express = require("express");
var app = express();
app.set("x-powered-by", "your mum");
const helmet = require("helmet");
app.use(helmet());
const killHeader = (req, res, next) => {
res.removeHeader("X-Powered-By");
next();
};
app.get("/", killHeader, (req, res) => {
res.header("X-powered-by", "A sack of rats");
res.removeHeader("X-Powered-By");
res.send("Hello world without x-powered headers");
});
app.disable("x-powered-by");
app.listen(3000, function () {
console.log("Running");
});
I feel like I must be missing a key bit of information as to where headers get generated and sent from, as no combination of the above strategies makes a differences when inspected in the network tab of Chrome. The environment is windows, run via VSCode, but I have the same problem on Ngix in Ubuntu.