Helper signature.attachRequestId(res) only takes the response.
Reach the request.res.req.get(...) reads a request header.
Set a response header.res.set(...) echoes the id back.
Alternative. Passing (req, res) is often clearer — use that when you can.
Compatibility
Runtime Support
res.req is an Express.js response property. It runs on a Node.js server (Express 5 needs Node.js 18+). Browsers do not have this API.
✓ Server · Express 4 & 5
res.req
Works wherever Express runs: Node.js is the primary target. Bun and Deno can run many Express apps with compatibility layers. Not available in the browser.
ServerNode.js runtime API
Node.js18+ for Express 5 · 14+ typical for Express 4
Supported
BunExpress-compatible server apps
Supported
DenoVia npm compatibility / adapters
Supported
res.reqExpress on Node.js
Bottom line: Study and run these examples with Node.js and the express package. Copy a snippet into a local file and start the server with node.
Frequently Asked Questions
It is a property on the response object that points to the request for the same HTTP cycle. In a handler, res.req === req is true.
Prefer the req argument in routes. Use res.req when a helper only receives res.
req.res points from the request back to the response. Express sets both links automatically.
No. It is the same request object — a back-pointer, not a copy.