Sign-out

The API endpoint to sign out a user is declared in the following route.

mern-skeleton/server/routes/auth.routes.js:

router.route('/auth/signout').get(authCtrl.signout)

When the Express app gets a GET request at '/auth/signout', it executes the signout controller function.

mern-skeleton/server/controllers/auth.controller.js:

const signout = (req, res) => {  res.clearCookie("t")  return res.status('200').json({    message: "signed out"  })}

The signout function clears the response cookie containing the signed JWT. This is an optional endpoint and not really necessary for auth purposes if cookies are not used at all in the frontend. With JWT, user state storage is the client's responsibility, and there are multiple options for client-side ...

Get Full-Stack React Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.