0

I want to send the jwt with a cookie but I can't see it in the browser.

This is the route that sends the cookie:

router.post('/signup', async (req, res) => {
    const { email, password } = req.body
    try {
        const user = await User.create({ email, password })
        const token = createToken(user._id)
        res.status(201).cookie('jwt', token, { httpOnly: true, maxAge: maxAge * 1000 })
    } catch (err) {
        const errors = handleErrors(err)
        res.json({ errors })
    }
})

I can't see the 'jwt' cookie in the chrome application tab.

I'm sure that the server works perfectly.

I'm sure that the token size is less than 4kb.

I'm using express 4.17.1.

Levi007
  • 315
  • 1
  • 3
  • 13

1 Answers1

0

Maybe this answer can solve your problem. Apparently you need to include

credentials: 'include'

in your request to specifies you need cookies.

roneicostajr
  • 89
  • 1
  • 5