Search code examples
node.jsbackbone.jssails.jsmarionettepassport.js

How to redirect from server, without the #url from the client?


I have a node.js (sail.js) project as server side, with backbone.marionette as client.

I'm using passport to determine if the user is authenticated.

module.exports = function(req, res, next)
{
  if (req.isAuthenticated())
        return next();
  else  
    res.redirect('/login');
}

My problem is:

if the current url is: http://localhost:1337/#users (with #users from client), and the server session is timeout, the res.redirect('/login'); redirects the page with the client url, like this: http://localhost:1337/login#users

Is there a way to redirect without the #url ?


Solution

  • Found a solusion:

    We can workaround this problem by redirecting to /login#. This should do the trick and remove the hash from the URL.