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: {
|
||||
'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;
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ exports.handleErrors = function (err, req, res, next) { // eslint-disable-line n
|
||||
|
||||
var 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);
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user