Skip to content
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

Revert "fix: make sure body can be read using nodejs runtime in middleware" #77690

Merged
merged 1 commit into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions packages/next/src/server/next-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1626,12 +1626,7 @@ export default class NextNodeServer extends BaseServer<

result = await adapterFn({
handler: middlewareModule.middleware || middlewareModule,
request: {
...requestData,
body: !['HEAD', 'GET'].includes(params.request.method)
? requestData.body?.cloneBodyStream()
: undefined,
},
request: requestData,
page: 'middleware',
})
} else {
Expand Down
4 changes: 0 additions & 4 deletions test/e2e/middleware-general/app/middleware-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,6 @@ export async function middleware(request) {
throw new Error('test error')
}

if (url.pathname === '/request-body' && request.method === 'POST') {
return NextResponse.json(await request.json())
}

const original = new URL(request.url)
return NextResponse.next({
headers: {
Expand Down
4 changes: 0 additions & 4 deletions test/e2e/middleware-general/app/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,6 @@ export async function middleware(request) {
throw new Error('test error')
}

if (url.pathname === '/request-body' && request.method === 'POST') {
return NextResponse.json(await request.json())
}

const original = new URL(request.url)
return NextResponse.next({
headers: {
Expand Down
11 changes: 0 additions & 11 deletions test/e2e/middleware-general/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -824,17 +824,6 @@ describe('Middleware Runtime', () => {
}/sha.json?hello=goodbye`,
])
})

it(`should read request body`, async () => {
const body = { hello: 'world' }
const res = await fetchViaHTTP(next.url, '/request-body', undefined, {
body: JSON.stringify(body),
headers: { 'content-type': 'application/json' },
method: 'POST',
})

expect(await res.json()).toEqual(body)
})
}
describe('with i18n', () => {
setup({ i18n: true })
Expand Down
Loading