mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
`expect` is an unsupported header for undici: https://github.com/nodejs/undici/blob/c83b084879fa0bb8e0469d31ec61428ac68160d5/lib/core/request.js#L354 -- this filters it out so that the API routes don't throw an internal server error if that header is included. Also added a test case for the previously submitted PR that was added for `content-length: 0` - x-ref: #53843 Fixes #53822 (erroneously closed by a content-length issue being fixed)
50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
import { createNextDescribe } from 'e2e-utils'
|
|
|
|
createNextDescribe(
|
|
'ipc-forbidden-headers',
|
|
{
|
|
files: __dirname,
|
|
},
|
|
({ next }) => {
|
|
it('should not error if expect header is included', async () => {
|
|
let res = await next.fetch('/api/pages-api', {
|
|
method: 'POST',
|
|
headers: { expect: '100-continue' },
|
|
})
|
|
let text = await res.text()
|
|
|
|
expect(text).toEqual('Hello, Next.js!')
|
|
|
|
res = await next.fetch('/api/app-api', {
|
|
method: 'POST',
|
|
headers: {
|
|
expect: '100-continue',
|
|
},
|
|
})
|
|
text = await res.text()
|
|
|
|
expect(text).toEqual('Hello, Next.js!')
|
|
expect(next.cliOutput).not.toContain('UND_ERR_NOT_SUPPORTED')
|
|
})
|
|
|
|
it("should not error on content-length: 0 if request shouldn't contain a payload", async () => {
|
|
let res = await next.fetch('/api/pages-api', {
|
|
method: 'DELETE',
|
|
headers: { 'content-length': '0' },
|
|
})
|
|
|
|
expect(res.status).toBe(200)
|
|
|
|
res = await next.fetch('/api/app-api', {
|
|
method: 'DELETE',
|
|
headers: { 'content-length': '0' },
|
|
})
|
|
|
|
expect(res.status).toBe(200)
|
|
expect(next.cliOutput).not.toContain(
|
|
'UND_ERR_REQ_CONTENT_LENGTH_MISMATCH'
|
|
)
|
|
})
|
|
}
|
|
)
|