Skip to content

Commit 33ba2ba

Browse files
committed
Update middleware request header
1 parent 5df8025 commit 33ba2ba

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

packages/next/src/server/lib/server-ipc/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const INTERNAL_HEADERS = [
4545
'x-middleware-set-cookie',
4646
'x-middleware-skip',
4747
'x-middleware-override-headers',
48+
'x-middleware-subrequest',
4849
'x-middleware-next',
4950
'x-now-route-matches',
5051
'x-matched-path',

test/e2e/middleware-general/test/index.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,19 @@ describe('Middleware Runtime', () => {
144144
}
145145
}
146146

147+
it('should filter request header properly', async () => {
148+
const res = await next.fetch('/redirect-to-somewhere', {
149+
headers: {
150+
'x-middleware-subrequest':
151+
'middleware:middleware:middleware:middleware:middleware',
152+
},
153+
redirect: 'manual',
154+
})
155+
156+
expect(res.status).toBe(307)
157+
expect(res.headers.get('location')).toContain('/somewhere')
158+
})
159+
147160
it('should handle 404 on fallback: false route correctly', async () => {
148161
const res = await next.fetch('/ssg-fallback-false/first')
149162
expect(res.status).toBe(200)

0 commit comments

Comments
 (0)