req.set() 📌
Express
Set request headers like response headers inCompatible with any node version running Express
Why does this matter?
Updating request headers directly in express isn't supported in the same manner as res.set()
For example, you lose the ability to fetch those headers in a case-insensitive manner such as with req.get()
reqheaders'Content-Type' = 'application/json';req // => undefined
Usage
It uses the same API as res.set()
var reqSet = ; app;
// If an object is passed, it will be stringified req;req // => '{"complex":true}'
There's also a middleware for one-time application use so each request is extended with .set()
var reqSet = ;app;