mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-27 00:52:36 +03:00
Fixed express app stacking
refs https://github.com/TryGhost/Toolbox/issues/152 - Because the root app module was initialized only once per runtime it caused all the express apps to stack on each other causing all sorts of strange behavior when trying to test redirects/vhost mounts etc. Lesson here: be very cautious of how the module is initialized, an explicit function is almost always a better way!
This commit is contained in:
parent
91338b23d9
commit
abcd715907
12
core/app.js
12
core/app.js
@ -27,10 +27,14 @@ const maintenanceMiddleware = (req, res, next) => {
|
||||
fs.createReadStream(path.resolve(__dirname, './server/views/maintenance.html')).pipe(res);
|
||||
};
|
||||
|
||||
const rootApp = express('root');
|
||||
rootApp.use(sentry.requestHandler);
|
||||
const rootApp = () => {
|
||||
const app = express('root');
|
||||
app.use(sentry.requestHandler);
|
||||
|
||||
rootApp.enable('maintenance');
|
||||
rootApp.use(maintenanceMiddleware);
|
||||
app.enable('maintenance');
|
||||
app.use(maintenanceMiddleware);
|
||||
|
||||
return app;
|
||||
};
|
||||
|
||||
module.exports = rootApp;
|
||||
|
@ -371,7 +371,7 @@ async function bootGhost({backend = true, frontend = true, server = true} = {})
|
||||
|
||||
// Step 2 - Start server with minimal app in global maintenance mode
|
||||
debug('Begin: load server + minimal app');
|
||||
const rootApp = require('./app');
|
||||
const rootApp = require('./app')();
|
||||
|
||||
if (server) {
|
||||
const GhostServer = require('./server/ghost-server');
|
||||
|
Loading…
Reference in New Issue
Block a user