diff --git a/src/middleware/middleware.js b/src/middleware/middleware.js index 2d5faace76..111b0b1ceb 100644 --- a/src/middleware/middleware.js +++ b/src/middleware/middleware.js @@ -69,7 +69,7 @@ middleware.redirectToAccountIfLoggedIn = function(req, res, next) { middleware.redirectToLoginIfGuest = function(req, res, next) { if (!req.user || parseInt(req.user.uid, 10) === 0) { - req.session.returnTo = nconf.get('relative_path') + req.url; + req.session.returnTo = nconf.get('relative_path') + req.url.replace(/^\/api/, ''); return res.redirect(nconf.get('relative_path') + '/login'); } else { next();