Skip to content

Commit 9bb10b1

Browse files
davecarlsonztanner
andauthored
Delete errorneous empty content length header (#53843)
fixes #53822 PR #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 <[email protected]>
1 parent 6f7ffad commit 9bb10b1

File tree

1 file changed

+6
-0
lines changed
  • packages/next/src/server/lib/server-ipc

1 file changed

+6
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ export const filterReqHeaders = (
1717
headers: Record<string, undefined | string | number | string[]>,
1818
forbiddenHeaders: string[]
1919
) => {
20+
// Some browsers are not matching spec and sending Content-Length: 0. This causes issues in undici
21+
// https://github.com/nodejs/undici/issues/2046
22+
if (headers['content-length'] && headers['content-length'] === '0') {
23+
delete headers['content-length']
24+
}
25+
2026
for (const [key, value] of Object.entries(headers)) {
2127
if (
2228
forbiddenHeaders.includes(key) ||

0 commit comments

Comments
 (0)