Skip to content

Request body can't be read when running middleware in nodejs runtime #77551

@kevva

Description

@kevva

Link to the code that reproduces this issue

https://github.com/kevva/next-bugs/tree/node-middleware-bug

To Reproduce

  1. Start the application in development (next dev)
  2. Send a POST request with a body
curl --location 'http://localhost:3000/' \
  --header 'Content-Type: application/json' \
  --data '{"foo": "bar"}'

Current vs. Expected behavior

Current behaviour

When reading the body, the app will fail with the following error:

⨯ SyntaxError: "[object Object]" is not valid JSON
    at JSON.parse (<anonymous>)

Expected behaviour

The middleware should be able to read the body.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.4.0: Tue Mar  4 21:05:34 PST 2025; root:xnu-11417.100.576.505.3~2/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 23.10.0
  npm: 10.2.4
  Yarn: 1.22.21
  pnpm: 8.15.7
Relevant Packages:
  next: 15.3.0-canary.24 // Latest available version is detected (15.3.0-canary.24).
  eslint-config-next: N/A
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.8.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Middleware

Which stage(s) are affected? (Select all that apply)

next dev (local), next start (local)

Additional context

This works fine when running the middleware with the Edge runtime and only happens when running it in Node.js.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions