Adds headers to all responses.
webpack.config.js
module.exports = {
// ...
devServer: {
headers: {
"X-Custom-Header": "yes",
},
},
};To run this example use the following command:
npx webpack serve --open- The script should open
http://localhost:8080/. - You should see the text on the page itself change to read
Success!. - Open the console in your browser's devtools and select the Network tab.
- Find
main.js. The response headers should containX-Custom-Header: yes.