mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #908] [MERGED] Preserve middleware headers on app boundary responses #937
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#937
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/908
Author: @NathanDrake2406
Created: 4/26/2026
Status: ✅ Merged
Merged: 4/26/2026
Merged by: @james-elicx
Base:
main← Head:nathan/middleware-boundary-headers📝 Commits (2)
5760834Preserve middleware headers on app boundary responsese587ef4test: stabilize app router redirect e2e📊 Changes
11 files changed (+399 additions, -89 deletions)
View changed files
📝
packages/vinext/src/entries/app-rsc-entry.ts(+28 -8)📝
packages/vinext/src/server/app-page-boundary-render.ts(+4 -0)📝
packages/vinext/src/server/app-page-boundary.ts(+10 -1)📝
packages/vinext/src/server/app-page-execution.ts(+34 -8)📝
packages/vinext/src/server/app-page-stream.ts(+7 -3)📝
tests/__snapshots__/entry-templates.test.ts.snap(+168 -48)📝
tests/app-page-boundary-render.test.ts(+85 -0)📝
tests/app-page-execution.test.ts(+35 -1)📝
tests/app-router.test.ts(+18 -0)📝
tests/e2e/app-router/rsc-fetch-errors.spec.ts(+5 -19)📝
tests/e2e/helpers.ts(+5 -1)📄 Description
What changed
redirect(),notFound(),forbidden(), andunauthorized().Why
Middleware can set response headers such as auth rotation cookies,
Vary, CSP/HSTS, and other security headers. The success App Page path already merged those headers, but boundary and special-error paths rebuilt freshResponseobjects and dropped them. That made middleware behavior depend on whether the page rendered successfully or ended innotFound(), an error boundary, orredirect().Next.js keeps middleware response headers in routing-level response headers before final rendering, so these branches should retain the same response envelope.
Validation
vp run vinext#buildvp checkvp test run tests/app-page-response.test.ts tests/app-page-boundary-render.test.ts tests/app-page-execution.test.ts tests/app-page-render.test.ts tests/app-router.test.ts -t "generated code threads middleware headers into page boundary and special-error responses|generated code delegates page boundary rendering to typed helpers|middleware response headers|preserves middleware headers|builds redirect and fallback responses|falls back to a plain status response|app page"🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.