Is it possible to add a custom HTTP response header to the development server that runs with ng serve? I'd like to add this custom header specially in the response of the main html file request, although it'd fine if it was added for every resource (js files, etc.).
I found these two recent Angular issues:
- https://github.com/angular/angular-cli/issues/15095
- https://github.com/angular/angular-cli/issues/15729
But it's still unclear to me if it's even possible to do it, and if it's possible how to accomplish it.
I have added a proxy.config.js file (referenced from angular.json, section projects -> my-app -> architect -> serve -> options -> proxyConfig) and tried several configs, like the following one, with no luck:
module.exports = {
"/": {
'headers': {
'X-Custom-Foo': 'bar'
},
onProxyRes: (proxyRes, req, res) => {
proxyRes.headers['x-added'] = 'foobar';
}
},
'headers': {
'X-Custom-Foo': 'bar'
},
onProxyRes: (proxyRes, req, res) => {
proxyRes.headers['x-added'] = 'foobar';
}
};
Is it possible to do so without having to use a third-party server?
headerskey to have that effect, following the docs from Angular via Webpack to NPM doesn't suggest that option would do anything.headers(a desperate try), I'm also settingonProxyReswhich should work. Any clue what is the right way to accomplish it? Thanks!