Unverified Commit ceeb6c3f authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Mention header overriding behavior (#16089)

Closes: https://github.com/vercel/next.js/issues/16088
parent 23013317
...@@ -27,7 +27,6 @@ module.exports = { ...@@ -27,7 +27,6 @@ module.exports = {
}, },
], ],
}, },
,
] ]
}, },
} }
...@@ -38,6 +37,37 @@ module.exports = { ...@@ -38,6 +37,37 @@ module.exports = {
- `source` is the incoming request path pattern. - `source` is the incoming request path pattern.
- `headers` is an array of header objects with the `key` and `value` properties. - `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 Matching
Path matches are allowed, for example `/blog/:slug` will match `/blog/hello-world` (no nested paths): Path matches are allowed, for example `/blog/:slug` will match `/blog/hello-world` (no nested paths):
...@@ -59,8 +89,7 @@ module.exports = { ...@@ -59,8 +89,7 @@ module.exports = {
}, },
], ],
}, },
, ],
]
}, },
} }
``` ```
...@@ -86,8 +115,7 @@ module.exports = { ...@@ -86,8 +115,7 @@ module.exports = {
}, },
], ],
}, },
, ],
]
}, },
} }
``` ```
...@@ -109,7 +137,7 @@ module.exports = { ...@@ -109,7 +137,7 @@ module.exports = {
}, },
], ],
}, },
] ],
}, },
} }
``` ```
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment