First of all, everything works fine when running on localhost.
However, after deploying the app to Vercel when the user tries to log out it should clear cookies with res.clearCookie() but it doesn’t and when the page is refreshed the user remains logged in.
Also, after deploying the app to Vercel the new token is generating fine but is not being stored in the browser’s cookies.
here is the function to LogOut
async function userLogout(req,res){
try {
const tokenOption = {
httpOnly : true,
secure : true,
sameSite : 'None'
}
res.clearCookie("token",tokenOption)
res.clearCookie("refresh_token",tokenOption)
res.json({
message: "Logged out successfully",
error : false,
success : true,
data : []
})
}catch(err){
res.json({
message : err.message || err ,
error : true,
success : false,
})
}
}
module.exports = userLogout
I tried to debug but it was no luck as my localhost was running everything perfectly