next.js
962e5b16 - Fix(pages-router): restore Content-Length and ETag for /_next/data/ JSON responses (#90304)

Commit
46 days ago
Fix(pages-router): restore Content-Length and ETag for /_next/data/ JSON responses (#90304) ## What Removes the `Buffer.from()` wrapper when constructing `RenderResult` for `/_next/data/` JSON responses in the Pages Router handler. ## Why PR #80189 introduced `Buffer.from(JSON.stringify(result.value.pageData))` when building the data response. Since `RenderResult.isDynamic` checks `typeof this.response !== 'string'`, passing a `Buffer` (not a `string`) caused it to return `true`, making `sendRenderResult` treat the response as a dynamic stream — skipping `Content-Length` and `ETag` generation and falling back to `Transfer-Encoding: chunked`. This is a regression from v15.4.0 and breaks CDN-side compression for self-hosted deployments (e.g. CloudFront requires `Content-Length` to compress origin responses on-the-fly). ## Fix ```diff - Buffer.from(JSON.stringify(result.value.pageData)), + JSON.stringify(result.value.pageData), ``` ## Testing - Reproduction steps verified against the reporter's repro repo: https://github.com/bbrouse/nextjs-content-length-repro - ```diffcurl -sD - on /_next/data/<BUILD_ID>/index.json``` now returns Content-Length and ETag headers. ## Affected Area - Pages Router — /_next/data/ responses only - No impact on App Router - Single-line change, minimal blast radius Fixes #90281 --------- Co-authored-by: JJ Kasper <jj@jjsweb.site>
Author
Parents
Loading