'Modify Request Headers Using ExpressJs
Is it possible to modify request headers using ExpressJs?
I have an expressjs app server that interfaces with multiple backend services and I'd like to have this app server modify the cookies in the request such that any calls it makes to the backend services contain the new cookies.
How would I go about doing this?
Solution 1:[1]
Check this out! Headers in ExpressJS.
app.get((req, res) => {
console.log('Request headers received:', req.headers);
res.header('Cookie', 'Yummm...'); // Setting header!
console.log('Final response headers:', res.headers);
res.send();
});
But since you are looking to use cookies, you might like to check this option out as well. Cookies in ExpressJS
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Trishant Pahwa |