-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: allow array for headers
option
#3847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e9780ab
feat: allow array for `headers` option
snitin315 4d935fa
test: add validation tests
snitin315 9cd2cd6
test: add e2e tests
snitin315 b940037
docs: add example
snitin315 fde859a
refactor: schema
snitin315 dbb6de4
test: more
snitin315 cde5319
refactor: code
snitin315 f2a2d9c
refactor: code
snitin315 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# headers option as an object | ||
|
||
Adds headers to all responses. | ||
|
||
**webpack.config.js** | ||
|
||
```js | ||
module.exports = { | ||
// ... | ||
devServer: { | ||
headers: [ | ||
{ | ||
key: "X-Foo", | ||
value: "value1", | ||
}, | ||
{ | ||
key: "X-Bar", | ||
value: "value2", | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
|
||
To run this example use the following command: | ||
|
||
```console | ||
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`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
"use strict"; | ||
|
||
const target = document.querySelector("#target"); | ||
|
||
target.classList.add("pass"); | ||
target.innerHTML = "Success!"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"use strict"; | ||
|
||
// our setup function adds behind-the-scenes bits to the config that all of our | ||
// examples need | ||
const { setup } = require("../../util"); | ||
|
||
module.exports = setup({ | ||
context: __dirname, | ||
entry: "./app.js", | ||
devServer: { | ||
headers: [ | ||
{ | ||
key: "X-Foo", | ||
value: "value1", | ||
}, | ||
{ | ||
key: "X-Bar", | ||
value: "value2", | ||
}, | ||
], | ||
}, | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.