mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-20 23:40:38 +01:00
feat: #9533, allow redirect in build hooks
This commit is contained in:
@@ -33,10 +33,16 @@ module.exports = function (middleware) {
|
||||
options.url = (req.baseUrl + req.path.replace(/^\/api/, ''));
|
||||
options.bodyClass = buildBodyClass(req, res, options);
|
||||
|
||||
const buildResult = await plugins.hooks.fire('filter:' + template + '.build', { req: req, res: res, templateData: options });
|
||||
const buildResult = await plugins.hooks.fire(`filter:${template}.build`, { req: req, res: res, templateData: options });
|
||||
if (res.headersSent) {
|
||||
return;
|
||||
}
|
||||
const templateToRender = buildResult.templateData.templateToRender || template;
|
||||
|
||||
const renderResult = await plugins.hooks.fire('filter:middleware.render', { req: req, res: res, templateData: buildResult.templateData });
|
||||
if (res.headersSent) {
|
||||
return;
|
||||
}
|
||||
options = renderResult.templateData;
|
||||
options._header = {
|
||||
tags: await meta.tags.parse(req, renderResult, res.locals.metaTags, res.locals.linkTags),
|
||||
|
||||
Reference in New Issue
Block a user