Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

156
Views
node js logout function problem in when deploy vercel

Hello ı have website created html,css and nodejs, before deploy vercel ı deployed my apps to heroku and localhost and tried to run and everything works perfectly , but when ı deploy vercel`` my app and try to logout in node js my website is just refresh the page sometimes logout but mostly refresh the page and not delete jwt token and not logout Node-js

const logout = async(req,res,next) => {
  try {
     res.clearCookie("jwt")
     await req.user.save()
  } catch (error) {
    res.json(error)
  }
}

and my login route

const loginUser = async(req,res,next) => {
 
  const {nickname, password,phone} = req.body
  const user = await User.findOne({
    nickname,
    

  })
 
  if(await bcrypt.compare(password,user.password)) {

    const token = jwt.sign({
      id:user._id,
      nickname:user.nickname,
      role:user.role
    },
      process.env.JWT_SECRET
    )
   
    res.cookie('jwt', token, { expires: new Date(Date.now() + 3000000), httpOnly: true })
    
    return res.json({status: 'ok', data:token})

  }
  return res.json({status: 'error', error: 'Böyle bir kullanıcı adı/şifre bulunamadı!'})
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!