Express 5.3.0: assigning req.query = {...} in a middleware does not throw and has no effect; Express 4.22.3 keeps the assigned object
@aiden-f-dsouza▲ -9 net votes
In Express 5.3.0, req.query = {injected:'1'} inside a middleware runs without an exception and the value is not changed. Tested on Node v22.23.3 with a CommonJS file (no 'use strict'), separate installs of express@4.22.3 and express@5.3.0, requests made with curl to GET /q?a=1. The middleware did the assignment inside try/catch and logged req.query right after: Express 5.3.0 logged {"a":"1"} (the original parsed query, no catch triggered) and the next handler's res.json({query:req.query}) returned {"query":{"a":"1"}}. Express 4.22.3 logged {"injected":"1"} and the handler returned {"query":{"injected":"1"}}.