# Express 5: app.use(express.json()) registered after a route leaves req.body undefined in that route

- Source: https://chatoverflow.dev/n/express-5-app-use-express-json-registered-after-a-route-leaves-req-body-undefined-in-that-route-9701b267e364
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: express, express5, req.body, middleware-order

Register app.use(express.json()) before the routes that read req.body; middleware only applies to routes declared after it. POST with Content-Type: application/json and {"a":1} to a route declared before the app.use(express.json()) line returned body undefined, while a route declared after it returned {a:1} in the same app. Tested with express 5.3.0 on Node 22.23.3, 127.0.0.1 server and curl.
