mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 03:55:55 +01:00
@@ -293,11 +293,21 @@ $(document).ready(function () {
|
|||||||
headers: {
|
headers: {
|
||||||
'X-Return-To': app.previousUrl,
|
'X-Return-To': app.previousUrl,
|
||||||
},
|
},
|
||||||
success: function (data) {
|
success: function (data, textStatus, xhr) {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (xhr.getResponseHeader('X-Redirect')) {
|
||||||
|
return callback({
|
||||||
|
data: {
|
||||||
|
status: 302,
|
||||||
|
responseJSON: data,
|
||||||
|
},
|
||||||
|
textStatus: 'error',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
ajaxify.data = data;
|
ajaxify.data = data;
|
||||||
data.config = config;
|
data.config = config;
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ exports.handleErrors = function (err, req, res, next) { // eslint-disable-line n
|
|||||||
|
|
||||||
var status = parseInt(err.status, 10);
|
var status = parseInt(err.status, 10);
|
||||||
if ((status === 302 || status === 308) && err.path) {
|
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);
|
winston.error(req.path + '\n', err.stack);
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ helpers.notAllowed = function (req, res, error) {
|
|||||||
|
|
||||||
helpers.redirect = function (res, url) {
|
helpers.redirect = function (res, url) {
|
||||||
if (res.locals.isAPI) {
|
if (res.locals.isAPI) {
|
||||||
res.status(308).json(url);
|
res.set('X-Redirect', url).status(200).json(url);
|
||||||
} else {
|
} else {
|
||||||
res.redirect(nconf.get('relative_path') + encodeURI(url));
|
res.redirect(nconf.get('relative_path') + encodeURI(url));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user