mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #288] [MERGED] Rebuild request context after middleware modifies headers #447
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#447
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/288
Author: @southpolesteve
Created: 3/6/2026
Status: ✅ Merged
Merged: 3/6/2026
Merged by: @southpolesteve
Base:
main← Head:fix/refresh-request-context-after-middleware📝 Commits (2)
51c5c12Rebuild request context after middleware modifies headers846648cFix request context parity in dev server and deploy entry📊 Changes
5 files changed (+52 additions, -6 deletions)
View changed files
📝
packages/vinext/src/deploy.ts(+9 -2)📝
packages/vinext/src/index.ts(+11 -2)📝
packages/vinext/src/server/prod-server.ts(+10 -2)📝
tests/fixtures/pages-basic/middleware.ts(+10 -0)📝
tests/pages-router.test.ts(+12 -0)📄 Description
Summary
RequestContextforhas/missingcondition matching before middleware ran. When middleware modified request headers (e.g. injecting cookies viax-middleware-request-cookie), config rules for redirects, rewrites, and custom headers evaluated against the original pre-middleware values instead of the updated ones.reqCtxconstruction to after middleware header unpacking so that config conditions see the current request state.Changes
packages/vinext/src/server/prod-server.ts: ChangedreqCtxfromconsttoletand added a secondrequestContextFromRequest()call after middleware headers are unpacked into the web request.tests/fixtures/pages-basic/middleware.ts: Added a path (/about?inject-login) that injects alogged-in=1cookie via middleware request headers.tests/pages-router.test.ts: New test verifying that confighas/missingconditions see middleware-injected cookies.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.