Skip to content

Commit

Permalink
Mention header overriding behavior (#16089)
Browse files Browse the repository at this point in the history
Closes: #16088
  • Loading branch information
ijjk authored Aug 12, 2020
1 parent 2301331 commit ceeb6c3
Showing 1 changed file with 34 additions and 6 deletions.
40 changes: 34 additions & 6 deletions docs/api-reference/next.config.js/headers.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ module.exports = {
},
],
},
,
]
},
}
Expand All @@ -38,6 +37,37 @@ module.exports = {
- `source` is the incoming request path pattern.
- `headers` is an array of header objects with the `key` and `value` properties.

## Header Overriding Behavior

If two headers match the same path and set the same header key, the last header key will override the first. Using the below headers, the path `/hello` will result in the header `x-hello` being `world` due to the last header value set being `world`.

```js
module.exports = {
async headers() {
return [
{
source: '/:path*',
headers: [
{
key: 'x-hello',
value: 'there',
},
],
},
{
source: '/hello',
headers: [
{
key: 'x-hello',
value: 'world',
},
],
},
],
},
}
```

## Path Matching

Path matches are allowed, for example `/blog/:slug` will match `/blog/hello-world` (no nested paths):
Expand All @@ -59,8 +89,7 @@ module.exports = {
},
],
},
,
]
],
},
}
```
Expand All @@ -86,8 +115,7 @@ module.exports = {
},
],
},
,
]
],
},
}
```
Expand All @@ -109,7 +137,7 @@ module.exports = {
},
],
},
]
],
},
}
```
Expand Down

0 comments on commit ceeb6c3

Please sign in to comment.