mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-30 02:25:55 +01:00
fix: #8883
This commit is contained in:
@@ -144,7 +144,7 @@ helpers.notAllowed = async function (req, res, error) {
|
||||
};
|
||||
|
||||
helpers.redirect = function (res, url, permanent) {
|
||||
if (res.locals.isAPI && !url.startsWith('/api/v3/')) {
|
||||
if (res.locals.isAPI) {
|
||||
res.set('X-Redirect', encodeURI(url)).status(200).json(url);
|
||||
} else {
|
||||
res.redirect(permanent ? 308 : 307, relative_path + encodeURI(url));
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const util = require('util');
|
||||
const nconf = require('nconf');
|
||||
|
||||
const db = require('../../database');
|
||||
const api = require('../../api');
|
||||
@@ -25,7 +26,7 @@ Users.redirectBySlug = async (req, res) => {
|
||||
|
||||
if (uid) {
|
||||
const path = req.path.split('/').slice(3).join('/');
|
||||
helpers.redirect(res, `/api/v3/users/${uid}/${path}`, true);
|
||||
res.redirect(308, nconf.get('relative_path') + encodeURI(`/api/v3/users/${uid}/${path}`));
|
||||
} else {
|
||||
helpers.formatApiResponse(404, res);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user