Answer the question
In order to leave comments, you need to log in
How to redirect after setting cookies in NextJS?
Hello, please tell me how to set cookies and make a redirect on the Next server?
Am I doing it right? I will be grateful for the answer
const token = jwt.sign(
{ userId: user.userId, username: user.username, email: user.email },
process.env.JWT_SECRET,
{
expiresIn: '30 days',
}
)
res.setHeader('Set-Cookie', serialize('token', token, { path: '/' }))
res.redirect(307, `/activate/${hash}`)
res.end();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question