🐛 Fixed "No default engine was specified and no extension was provided"

refs #9681

- we already had a protection against these situations when serving the site (theme)
- it can happen that we have to initialise the express engine in the error handler in case the first request to /ghost produces an error (e.g. 503)
- otherwise the underlying error message is hidden and Ghost doesn't render the error html template correctly
This commit is contained in:
kirrg001 2018-06-11 11:24:07 +02:00
parent f943acea58
commit 60cdfe29fe

View File

@ -134,6 +134,16 @@ _private.HTMLErrorRenderer = function HTMLErrorRender(err, req, res, next) { //
errorDetails: err.errorDetails || []
};
// e.g. if you serve the admin /ghost and Ghost returns a 503 because it generates the urls at the moment.
// This ensures that no matter what res.render will work here
// @TODO: put to prepare error function?
if (_.isEmpty(req.app.engines)) {
res._template = 'error';
req.app.engine('hbs', _private.createHbsEngine());
req.app.set('view engine', 'hbs');
req.app.set('views', config.get('paths').defaultViews);
}
res.render('error', data, function renderResponse(err, html) {
if (!err) {
return res.send(html);