Skip to content

Node.js based forum software built for the modern web

fix: #8883

Barış Soner Uşaklıf14e42d8bc81
diff --git a/src/controllers/helpers.js b/src/controllers/helpers.js
index cf07d469cb..8bbe2ffe1a 100644
--- a/src/controllers/helpers.js
+++ b/src/controllers/helpers.js
@@ -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));
diff --git a/src/controllers/write/users.js b/src/controllers/write/users.js
index 61bfc8827e..72f10dbfb0 100644
--- a/src/controllers/write/users.js
+++ b/src/controllers/write/users.js
@@ -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);
}