I am trying to remove x-powered-by header from response headers in angular cli project.As there is no direct access for express, so how can we remove header from all request's response header.
I tried following -
const PROXY_CONFIG = [
{
context: [
'/'
],
secure: false,
bypass: function (req, res) {
res.removeHeader('x-powered-by');
}
}
];
module.exports = PROXY_CONFIG;
But it worked only for first request, for all other request it didn't work.
I tried following as well but the function doesn't get triggered -
const PROXY_CONFIG = [
{
context: [
'/'
],
secure: false,
onProxyRes: function (proxyRes, req, res) {
delete proxyRes.headers['x-powered-by'];
}
}
];
module.exports = PROXY_CONFIG;
I referred following links -
Angular: add custom HTTP response headers to dev `ng serve`
How set proxy headers in proxy.config.json file for angularcli project