Skip to content

Commit

Permalink
Delete errorneous empty content length header (#53843)
Browse files Browse the repository at this point in the history
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 <1939140+ztanner@users.noreply.github.com>
  • Loading branch information
davecarlson and ztanner committed Aug 10, 2023
1 parent 6f7ffad commit 9bb10b1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/next/src/server/lib/server-ipc/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) ||
Expand Down

0 comments on commit 9bb10b1

Please sign in to comment.