Search code examples
node.jsexpressroutesstormpath

How do you customize the redirectURL of logout from the express-stormpath library?


I am using express-stormpath to handle user management functionality of my nodejs app. When the /logout route is accessed, the default redirectUrl is /. I am trying to redirect a user to /login after accessing /logout. According to the documentation, redirect logic can be customized by setting the redirectUrl option in the stormpath middleware like this:

app.use(stormpath.init(app, {
  redirectUrl: '/dashboard',
}));

However, setting this option seems to only affect the redirect logic of /login and /register, not /logout.

I tried the following, the following code but it didn't work.

app.use(stormpath.init(app, {
  logoutUrl: {
    redirectUrl: '/login' 
  }
}));

Solution

  • Try this:

    app.use(stormpath.init(app,{
        'postLogoutRedirectUrl': '/login'
    }));
    

    Whole bunch of other options can be found here