diff --git a/src/controllers/helpers.js b/src/controllers/helpers.js index 12a3327c55..3b3faa0622 100644 --- a/src/controllers/helpers.js +++ b/src/controllers/helpers.js @@ -49,7 +49,7 @@ helpers.redirect = function(res, url) { if (res.locals.isAPI) { res.status(302).json(url); } else { - res.redirect(url); + res.redirect(nconf.get('relative_path') + url); } }; diff --git a/src/middleware/middleware.js b/src/middleware/middleware.js index 62575d066b..34d2a79870 100644 --- a/src/middleware/middleware.js +++ b/src/middleware/middleware.js @@ -60,14 +60,14 @@ middleware.redirectToAccountIfLoggedIn = function(req, res, next) { if (err) { return next(err); } - helpers.redirect(res, '/user/' + userslug); + controllers.helpers.redirect(res, '/user/' + userslug); }); }; middleware.redirectToLoginIfGuest = function(req, res, next) { if (!req.user || parseInt(req.user.uid, 10) === 0) { req.session.returnTo = nconf.get('relative_path') + req.url.replace(/^\/api/, ''); - return res.redirect(nconf.get('relative_path') + '/login'); + return controllers.helpers.redirect(res, '/login'); } else { next(); } @@ -80,7 +80,7 @@ middleware.addSlug = function(req, res, next) { return next(err); } - helpers.redirect(res, name + encodeURI(slug)); + controllers.helpers.redirect(res, name + encodeURI(slug)); }); }