I'm trying to set-up a route that delete cookie containing a JWT on the client's browser.
To perform that, I'm using the res.ClearCookie function
public async logOut (req: Request, res: Response) {
res.clearCookie('auth-token', {httpOnly: true, path:'/', domain: 'localhost'});
console.log('cookie deleted')
}
I have seen that clearCookie function has to contain the same object that I passed during it creation, so here is the way I created it
const accessToken: string = jwt.sign({id: existingUser.id}, process.env.ACCESS_TOKEN_SECRET || 'tokensecret' )
return res.cookie('auth-token', accessToken, {httpOnly: true, path:'/', domain: 'localhost'}).json(mainWallet[0].id)
This way, the cookie isn't deleted when I try to logout.
Do you have an idea to fix that ?
Thanks,
Paul