0
Fork 0
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:
kirrg001 2018-08-10 17:34:52 +02:00 committed by Katharina Irrgang
parent 17833a669b
commit 0a4f34cdad
2 changed files with 7 additions and 5 deletions

View file

@ -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;
}

View file

@ -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();