mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Fixed express router reference after routes.yaml refresh
refs #9601, refs #9744 - the express router reference wasn't updated fully - the stack was the old router stack when you have uploaded a new routes.yaml file - this has caused e.g. that new redirects for channels/collections didn't work after the upload
This commit is contained in:
parent
17833a669b
commit
0a4f34cdad
2 changed files with 7 additions and 5 deletions
|
@ -146,6 +146,8 @@ class ParentRouter extends EventEmitter {
|
|||
}
|
||||
|
||||
isRedirectEnabled(routerType, slug) {
|
||||
debug('isRedirectEnabled', this.name, this.route && this.route.value, routerType, slug);
|
||||
|
||||
if (!this.data || !Object.keys(this.data.router)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,10 @@ var debug = require('ghost-ignition').debug('blog'),
|
|||
|
||||
let router;
|
||||
|
||||
function SiteRouter(req, res, next) {
|
||||
router(req, res, next);
|
||||
}
|
||||
|
||||
module.exports = function setupSiteApp(options = {}) {
|
||||
debug('Site setup start');
|
||||
|
||||
|
@ -128,11 +132,6 @@ module.exports = function setupSiteApp(options = {}) {
|
|||
debug('General middleware done');
|
||||
|
||||
router = siteRoutes(options);
|
||||
|
||||
function SiteRouter(req, res, next) {
|
||||
router(req, res, next);
|
||||
}
|
||||
|
||||
setPrototypeOf(SiteRouter, router);
|
||||
|
||||
// Set up Frontend routes (including private blogging routes)
|
||||
|
@ -150,6 +149,7 @@ module.exports = function setupSiteApp(options = {}) {
|
|||
module.exports.reload = () => {
|
||||
// https://github.com/expressjs/express/issues/2596
|
||||
router = siteRoutes({start: true});
|
||||
setPrototypeOf(SiteRouter, router);
|
||||
|
||||
// re-initialse apps (register app routers, because we have re-initialised the site routers)
|
||||
apps.init();
|
||||
|
|
Loading…
Add table
Reference in a new issue