Node.js based forum software built for the modern web
Fix #5793
Peter Jaszkowiak6cb844071517
diff --git a/public/src/ajaxify.js b/public/src/ajaxify.jsindex 26c9950254..9ca9052dc9 100644--- a/public/src/ajaxify.js+++ b/public/src/ajaxify.js@@ -293,11 +293,21 @@ $(document).ready(function () {headers: {'X-Return-To': app.previousUrl,},- success: function (data) {+ success: function (data, textStatus, xhr) {if (!data) {return;}+ if (xhr.getResponseHeader('X-Redirect')) {+ return callback({+ data: {+ status: 302,+ responseJSON: data,+ },+ textStatus: 'error',+ });+ }+ajaxify.data = data;data.config = config;diff --git a/src/controllers/errors.js b/src/controllers/errors.jsindex 99614f9e87..177bcaa769 100644--- a/src/controllers/errors.js+++ b/src/controllers/errors.js@@ -45,7 +45,7 @@ exports.handleErrors = function (err, req, res, next) { // eslint-disable-line nvar status = parseInt(err.status, 10);if ((status === 302 || status === 308) && err.path) {- return res.locals.isAPI ? res.status(status).json(err.path) : res.redirect(err.path);+ return res.locals.isAPI ? res.set('X-Redirect', err.path).status(200).json(err.path) : res.redirect(err.path);}winston.error(req.path + '\n', err.stack);diff --git a/src/controllers/helpers.js b/src/controllers/helpers.jsindex 761faafa82..8db1d6266f 100644--- a/src/controllers/helpers.js+++ b/src/controllers/helpers.js@@ -53,7 +53,7 @@ helpers.notAllowed = function (req, res, error) {helpers.redirect = function (res, url) {if (res.locals.isAPI) {- res.status(308).json(url);+ res.set('X-Redirect', url).status(200).json(url);} else {res.redirect(nconf.get('relative_path') + encodeURI(url));}