I want to remove / modify my react.js's response headers.
I want to for example remove the header "X-Powered-By".
Is there any way to do this?
Edit: I want to do this in REACT.JS, not express.
I want to remove / modify my react.js's response headers.
I want to for example remove the header "X-Powered-By".
Is there any way to do this?
Edit: I want to do this in REACT.JS, not express.
React.JS
as such does not generate any HTTP headers
. HTTP headers
may be added by your web server or possibly by a REST
client library such as Axios
. Please share more information on your setup.
Disabling Express's default X-Powered-By is as easy as:
const express = require('express')
const app = express()
app.disable('x-powered-by');
See
https://expressjs.com/en/api.html#app.settings.table
https://expressjs.com/en/api.html#app.disable
If you want to modify headers:
..., function(req, res) {
...
res.set('Content-Type', 'text/plain');
...
}
Your question already has an answer here: How can I set response header on express.js assets