Skip to content

Commit 3acb29f

Browse files
committed
test: some more test for custom headers
1 parent ff6a7a7 commit 3acb29f

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,30 @@
11
describe('custom headers', () => {
2-
it('should load custom headers', () => {
2+
it('should load custom headers for an SSG page', () => {
33
cy.request('/').then((request) => {
44
cy.wrap(request.headers['x-custom-header']).should('equal', 'my custom header value')
5+
cy.wrap(request.headers['x-custom-header-for-everything']).should(
6+
'equal',
7+
'my custom header for everything value',
8+
)
9+
})
10+
})
11+
12+
it('should load custom headers for a Netlify function', () => {
13+
cy.request('/api/hello/').then((request) => {
14+
cy.wrap(request.headers['x-custom-api-header']).should('equal', 'my custom api header value')
15+
cy.wrap(request.headers['x-custom-header-for-everything']).should(
16+
'equal',
17+
'my custom header for everything value',
18+
)
19+
})
20+
})
21+
22+
it('should load custom headers for an SSR page', () => {
23+
cy.request('/shows/250').then((request) => {
24+
cy.wrap(request.headers['x-custom-header-for-everything']).should(
25+
'equal',
26+
'my custom header for everything value',
27+
)
528
})
629
})
730
})

demos/default/next.config.js

+18
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,24 @@ module.exports = {
1919
},
2020
],
2121
},
22+
{
23+
source: '/api/:path*',
24+
headers: [
25+
{
26+
key: 'x-custom-api-header',
27+
value: 'my custom api header value',
28+
},
29+
],
30+
},
31+
{
32+
source: '/:path*',
33+
headers: [
34+
{
35+
key: 'x-custom-header-for-everything',
36+
value: 'my custom header for everything value',
37+
},
38+
],
39+
},
2240
]
2341
},
2442
trailingSlash: true,

0 commit comments

Comments
 (0)