How to set headers in api routes?
Unanswered
Naeemgg posted this in #help-forum
NaeemggOP
I want to set jwt token in headers just like this
but not sure how to do it.
res.setHeader('Set-Cookie', serialize('token', token, { httpOnly: true, path: '/' }));
res.status(200).json({ message: 'Logged in successfully' });
but not sure how to do it.
1 Reply
Asian black bear
You use the
cookies()
function to set cookies.