Skip to content

Latest commit

 

History

History
36 lines (29 loc) · 704 Bytes

File metadata and controls

36 lines (29 loc) · 704 Bytes

headers option as an object

Adds headers to all responses.

webpack.config.js

module.exports = {
  // ...
  devServer: {
    headers: [
      {
        key: "X-Foo",
        value: "value1",
      },
      {
        key: "X-Bar",
        value: "value2",
      },
    ],
  },
};

To run this example use the following command:

npx webpack serve --open

What should happen

  1. The script should open http://localhost:8080/.
  2. You should see the text on the page itself change to read Success!.
  3. Open the console in your browser's devtools and select the Network tab.
  4. Find main.js. The response headers should contain X-Foo: value1 and X-Bar: value2.