Auth0 Home Blog Docs

Having trouble with logout on the sample NodeJS app


#1

I have been going back and forth between the documentation and a few other forum post, but I for the life of me cannot figure out how to get the logout feature to work and clear the session.

Here is what I have tried

router.get(’/logout’, (req, res) => {
req.logout({
returnTo: “http%3A%2F%2Flocalhost:3000”,
client_id: “MYCLIENTIDHERE”
});
res.redirect(’/’);
});

and

// Perform session logout and redirect to homepage
router.get(’/v2/logout?returnTo=http%3A%2F%2Flocalhost:3000&client_id=MYCLIENTIDHERE’, (req, res) => {
req.logout();
res.redirect(’/’);
});

Is there something simple that I am missing? Please let me know if any additional information is needed. Thanks in advance!


Log out in sample NodeJS app not working
Log out in sample NodeJS app not working
#2

Hi @keepitsane

The first one you tried should be correct.

What’s the particular issue you are having? Are you receiving an error message?
The Auth0 logs can help identify the issue so it helps to check those as well.


#3

When I try the first one I get no response at all, and nothing in the logs even shows up for the event.

I have also tried including these as the allowed logout urls http://localhost:3000/logout, http://localhost:3000

It still just does nothing just redirects to homepage after I click the logout button. Then when I click the sign in it does not even prompt to login back in, just pushes the previously signed in user through to the application.


#4

Can you provide me with a HAR file so I can investigate why the browser says “ok” while you’re still logged in?
How to troubleshoot with HAR files and steps to generate a HAR file:

Thanks for help and sorry for inconveniences!


#5

@konrad.sopala

Here is the HAR file that you requested. Also sorry about the duplicate posts.
localhost.har (679.4 KB)

Please let me know if any additional information is needed! Thanks once again for the help