fix: replace original request body after middleware execution (#77662)#7
fix: replace original request body after middleware execution (#77662)#7MitchLewis930 wants to merge 1 commit intopr_037_beforefrom
Conversation
…#77662) In vercel#77553 we fixed reading the request body in middleware using the `nodejs` runtime. However, this caused issues with subsequent reads like in server actions. In sandbox, [we run](https://github.com/vercel/next.js/blob/1e62ce2c61048ddc0297f1a4f268894541975521/packages/next/src/server/web/sandbox/sandbox.ts#L146-L148) `.finalize()` after middleware is executed so we should do the same here. Fixes vercel#77646 --------- Co-authored-by: JJ Kasper <jj@jjsweb.site>
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨No code suggestions found for the PR. |
User description
PR_037
PR Type
Bug fix
Description
Clone request body before middleware execution to prevent consumption
Finalize body stream after middleware completes for subsequent reads
Enable nodejs runtime middleware testing with new test configurations
Add test variants for server actions with node middleware runtime
Diagram Walkthrough
File Walkthrough
1 files
Clone and finalize request body in middleware8 files
New nodejs runtime middleware test fixtureRemove runtime config from default middlewareAdd node middleware test variant supportNew test file for form state with node middlewareAdd node middleware test variant supportNew test file for actions with node middlewareAdd node middleware test variant and configNew test file for size limit with node middleware1 files
Enable nodeMiddleware experimental feature