diff --git a/src/controllers/helpers.js b/src/controllers/helpers.js index 6068de3091..efdf97e811 100644 --- a/src/controllers/helpers.js +++ b/src/controllers/helpers.js @@ -136,10 +136,10 @@ helpers.notAllowed = function (req, res, error) { }); } } else if (res.locals.isAPI) { - req.session.returnTo = nconf.get('relative_path') + req.url.replace(/^\/api/, ''); + req.session.returnTo = req.url.replace(/^\/api/, ''); res.status(401).json('not-authorized'); } else { - req.session.returnTo = nconf.get('relative_path') + req.url; + req.session.returnTo = req.url; res.redirect(nconf.get('relative_path') + '/login'); } }); diff --git a/src/middleware/user.js b/src/middleware/user.js index 86cb998332..f43319e1dd 100644 --- a/src/middleware/user.js +++ b/src/middleware/user.js @@ -229,7 +229,7 @@ module.exports = function (middleware) { } returnTo = returnTo.replace(/^\/api/, ''); - req.session.returnTo = nconf.get('relative_path') + returnTo; + req.session.returnTo = returnTo; req.session.forceLogin = 1; if (res.locals.isAPI) { res.status(401).json({});