mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 17:16:14 +01:00
fix(remountable-routes): bug with user routes remounting to itself
This commit is contained in:
@@ -140,8 +140,9 @@ async function addCoreRoutes(app, router, middleware) {
|
|||||||
account: 'user',
|
account: 'user',
|
||||||
};
|
};
|
||||||
await Promise.all(remountable.map(async (mount) => {
|
await Promise.all(remountable.map(async (mount) => {
|
||||||
const original = mount;
|
const method = mount;
|
||||||
mount = mountHash[mount] || mount;
|
const original = mountHash[mount] || mount;
|
||||||
|
mount = original;
|
||||||
|
|
||||||
({ mount } = await plugins.hooks.fire('filter:router.add', { mount }));
|
({ mount } = await plugins.hooks.fire('filter:router.add', { mount }));
|
||||||
if (mount === null) { // do not mount at all
|
if (mount === null) { // do not mount at all
|
||||||
@@ -152,12 +153,12 @@ async function addCoreRoutes(app, router, middleware) {
|
|||||||
if (mount !== original) {
|
if (mount !== original) {
|
||||||
// Set up redirect for fallback handling (some js/tpls may still refer to the traditional mount point)
|
// Set up redirect for fallback handling (some js/tpls may still refer to the traditional mount point)
|
||||||
winston.info(`[router] /${original} prefix re-mounted to /${mount}. Requests to /${original}/* will now redirect to /${mount}`);
|
winston.info(`[router] /${original} prefix re-mounted to /${mount}. Requests to /${original}/* will now redirect to /${mount}`);
|
||||||
router.use(new RegExp(`/(api/)?${mountHash[original] || original}`), (req, res) => {
|
router.use(new RegExp(`/(api/)?${original}`), (req, res) => {
|
||||||
controllerHelpers.redirect(res, `${nconf.get('relative_path')}/${mount}${req.path}`);
|
controllerHelpers.redirect(res, `${nconf.get('relative_path')}/${mount}${req.path}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_mounts[original](router, mount, middleware, controllers);
|
_mounts[method](router, mount, middleware, controllers);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const relativePath = nconf.get('relative_path');
|
const relativePath = nconf.get('relative_path');
|
||||||
|
|||||||
Reference in New Issue
Block a user