How to log a user out with Replit Auth in Node.js

I am currently writing a auth system for a fourm I am making, but I cannot figure out how to log the user out. Is there a way to log the user out while using Replit Auth?

Repl link:

//This is what I have for the coder right now, what do I need to add or remove
// To make this work
app.get('/logout', (req, res) => {
  user = getUserInfo(req);
  res.send("Logged Out");
1 Like

You could clear the cookie of the page (if there is not a built-in function.) If your page doesn’t store any other cookies besides ReplAuth, then I think you could just redirect to a page that runs


and it will log them out of your site.


I have sloved it, I had to put a bunch more stuff in it for it to work

1 Like

What did you do? (in case other people find this post looking for an answer)

And then mark that post as a solution.

1 Like

I used'/api/logout', (req, res) =>{ res.clearCookie('REPL_AUTH',{path:'/',domain:''}); console.log("User is logged out."); return res.status(200).redirect('/'); });


Well yeah, document is only in frontend JS, not Node

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.