Delete errorneous empty content length header (#53843)
fixes https://github.com/vercel/next.js/issues/53822 PR https://github.com/vercel/next.js/pull/53368 introduced a regression causing fetch with custom headers to fail in safari. There are known issues with uncidi when a content-length: 0 header exists. When performing a custom fetch in safari, this header is present. When performing a custom fetch in chrome, this header is not present. Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com>
This commit is contained in:
parent
6f7ffadc86
commit
9bb10b1cb3
1 changed files with 6 additions and 0 deletions
|
@ -17,6 +17,12 @@ export const filterReqHeaders = (
|
|||
headers: Record<string, undefined | string | number | string[]>,
|
||||
forbiddenHeaders: string[]
|
||||
) => {
|
||||
// Some browsers are not matching spec and sending Content-Length: 0. This causes issues in undici
|
||||
// https://github.com/nodejs/undici/issues/2046
|
||||
if (headers['content-length'] && headers['content-length'] === '0') {
|
||||
delete headers['content-length']
|
||||
}
|
||||
|
||||
for (const [key, value] of Object.entries(headers)) {
|
||||
if (
|
||||
forbiddenHeaders.includes(key) ||
|
||||
|
|
Loading…
Reference in a new issue