mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #428] [MERGED] fix: align Pages API body parsing and res.send(Buffer) #568
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#568
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/428
Author: @JaredStowell
Created: 3/10/2026
Status: ✅ Merged
Merged: 3/11/2026
Merged by: @james-elicx
Base:
main← Head:jstowell/fix-pages-api-body-parity📝 Commits (5)
1ca97c9Fix Buffer handling in Pages API res09d6224fix: skip reporting handled Pages API parse errors37eb489Merge remote-tracking branch 'origin/main' into jstowell/fix-pages-api-body-parityb41e76eaddress review: blank line nit, content-length parity for Buffer, fix duplicate Content-Length in sendCompressedf3f03f7fix: set content-length for Buffer in production res.send() to match dev parity📊 Changes
8 files changed (+266 additions, -68 deletions)
View changed files
📝
packages/vinext/src/entries/pages-server-entry.ts(+38 -17)📝
packages/vinext/src/server/api-handler.ts(+28 -7)📝
packages/vinext/src/server/prod-server.ts(+4 -1)📝
tests/__snapshots__/entry-templates.test.ts.snap(+54 -29)📝
tests/api-handler.test.ts(+58 -14)➕
tests/fixtures/pages-basic/pages/api/echo-body.ts(+5 -0)➕
tests/fixtures/pages-basic/pages/api/send-buffer.ts(+5 -0)📝
tests/pages-router.test.ts(+74 -0)📄 Description
Summary
Fix three Pages Router API compatibility gaps to match Next.js behavior more closely:
res.send(Buffer)now sends raw bytes withapplication/octet-streaminstead of JSON-stringifying Buffer metadataapplication/x-www-form-urlencodedbody parsing now preserves repeated keys as arrays400 Invalid JSONinstead of falling through as a raw stringThis updates both Pages API paths so dev and production stay in sync:
packages/vinext/src/server/api-handler.tspackages/vinext/src/entries/pages-server-entry.tsTests
Added coverage for all three cases in:
tests/api-handler.test.tstests/pages-router.test.tsAdded Pages Router fixture routes for integration coverage:
tests/fixtures/pages-basic/pages/api/echo-body.tstests/fixtures/pages-basic/pages/api/send-buffer.tsUpdated:
tests/__snapshots__/entry-templates.test.ts.snapVerification
Ran:
pnpm test tests/api-handler.test.tspnpm test tests/pages-router.test.tspnpm test tests/entry-templates.test.ts -upnpm run fmtpnpm run typecheckpnpm test🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.