v1.18.x
Barış Soner Uşaklı 4 years ago
parent 29c2ca94f4
commit f14e42d8bc

@ -144,7 +144,7 @@ helpers.notAllowed = async function (req, res, error) {
}; };
helpers.redirect = function (res, url, permanent) { 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); res.set('X-Redirect', encodeURI(url)).status(200).json(url);
} else { } else {
res.redirect(permanent ? 308 : 307, relative_path + encodeURI(url)); res.redirect(permanent ? 308 : 307, relative_path + encodeURI(url));

@ -1,6 +1,7 @@
'use strict'; 'use strict';
const util = require('util'); const util = require('util');
const nconf = require('nconf');
const db = require('../../database'); const db = require('../../database');
const api = require('../../api'); const api = require('../../api');
@ -25,7 +26,7 @@ Users.redirectBySlug = async (req, res) => {
if (uid) { if (uid) {
const path = req.path.split('/').slice(3).join('/'); 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 { } else {
helpers.formatApiResponse(404, res); helpers.formatApiResponse(404, res);
} }

Loading…
Cancel
Save