I have a middleware doing some auth. In this auth-method I need to set a response header.
server.get('/api/users, auth(), getUsers);
My authmethod:
module.exports = (isProduction) => {
return function(req, res, next){
...
next();
}
}
How do I attach a header in this auth function?
I assume you are using express.js
. In express, there is a set
function (documentation here. You can use it like this
res.set('<header name>', '<header value>')
before calling next()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With