Skip to content

Commit

Permalink
Apply fix(stream): Allows body larger than 16 KiB with middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Nov 8, 2022
1 parent f3fc912 commit 58dcf30
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/next/server/body-streams.ts
Expand Up @@ -90,8 +90,14 @@ export function getClonableBody<T extends IncomingMessage>(
const input = buffered ?? readable
const p1 = new PassThrough()
const p2 = new PassThrough()
input.pipe(p1)
input.pipe(p2)
input.on('data', (chunk) => {
p1.push(chunk)
p2.push(chunk)
})
input.on('end', () => {
p1.push(null)
p2.push(null)
})
buffered = p2
return p1
},
Expand Down

0 comments on commit 58dcf30

Please sign in to comment.