-
Notifications
You must be signed in to change notification settings - Fork 1
fix: replace original request body after middleware execution (#77662) #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: pr_037_before
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| process.env.TEST_NODE_MIDDLEWARE = 'true' | ||
|
|
||
| require('./app-action-form-state.test') |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| process.env.TEST_NODE_MIDDLEWARE = 'true' | ||
|
|
||
| require('./app-action.test') |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| process.env.TEST_NODE_MIDDLEWARE = 'true' | ||
|
|
||
| require('./app-action-size-limit-invalid.test') | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| // Ensure that https://github.com/vercel/next.js/issues/56286 is fixed. | ||
| import { NextResponse } from 'next/server' | ||
|
|
||
| export async function middleware(req) { | ||
| if (req.nextUrl.pathname.includes('rewrite-to-static-first')) { | ||
| req.nextUrl.pathname = '/static/first' | ||
| return NextResponse.rewrite(req.nextUrl) | ||
| } | ||
|
|
||
| return NextResponse.next() | ||
| } | ||
|
|
||
| /** | ||
| * @type {import('next/server').MiddlewareConfig} | ||
| */ | ||
| export const config = { | ||
| runtime: 'nodejs', | ||
| } | ||
|
Comment on lines
+13
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, let's understand the repository structure and find Next.js type definitions
git ls-files | grep -E "(middleware|server)" | head -20Repository: Signal65/next.js-CodeRabbit Length of output: 1103 🏁 Script executed: # Search for MiddlewareConfig type definition in the codebase
rg -n "type MiddlewareConfig|interface MiddlewareConfig" --type=ts -A 10Repository: Signal65/next.js-CodeRabbit Length of output: 4557 🏁 Script executed: # Also search for middleware config exports to understand the type structure
rg -n "export.*MiddlewareConfig" --type=tsRepository: Signal65/next.js-CodeRabbit Length of output: 1073 🏁 Script executed: # Check if runtime property is used in middleware configs anywhere
rg -n "runtime.*nodejs" --type=ts -C 3Repository: Signal65/next.js-CodeRabbit Length of output: 25948 🏁 Script executed: # Let's check the MiddlewareConfigInputSchema to see all supported properties
sed -n '95,150p' packages/next/src/build/segment-config/middleware/middleware-config.tsRepository: Signal65/next.js-CodeRabbit Length of output: 1417 🏁 Script executed: # Let's check the actual file under review to see what it contains
cat -n test/e2e/app-dir/actions/middleware-node.jsRepository: Signal65/next.js-CodeRabbit Length of output: 648 🏁 Script executed: # Also check if there's a separate type definition for runtime in middleware context
rg -n "runtime.*nodejs" packages/next/src/build/segment-config/middleware/ -A 2 -B 2Repository: Signal65/next.js-CodeRabbit Length of output: 53 🏁 Script executed: # Search for where runtime is parsed/validated in middleware config
rg -n "runtime" packages/next/src/build/segment-config/middleware/middleware-config.ts -A 2 -B 2Repository: Signal65/next.js-CodeRabbit Length of output: 53 🏁 Script executed: # Check the types exported from next/server to understand what types are available
cat packages/next/src/server/web/types.tsRepository: Signal65/next.js-CodeRabbit Length of output: 1931 🏁 Script executed: # Let's look at what types are available in next/server.d.ts
cat packages/next/server.d.ts | head -30Repository: Signal65/next.js-CodeRabbit Length of output: 1286 🏁 Script executed: # Search for all type definitions that include runtime in middleware context
rg -n "type.*Middleware.*Config|interface.*Middleware.*Config" packages/next/src --type=ts -A 5Repository: Signal65/next.js-CodeRabbit Length of output: 8896 Update JSDoc type annotation to include the The
Relevant code snippet/**
* `@type` {import('next/server').MiddlewareConfig}
*/
export const config = {
runtime: 'nodejs',
}🤖 Prompt for AI Agents |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restore
TEST_NODE_MIDDLEWAREafter the suite to avoid env leakage.Since this sets a global env var at module scope, it can bleed into subsequent test files in the same worker. Consider saving the previous value and restoring it in
afterAll.🔧 Suggested patch
🤖 Prompt for AI Agents