From 60cdfe29fea0a3cb5b30223daab1dc3792d2cf21 Mon Sep 17 00:00:00 2001 From: kirrg001 Date: Mon, 11 Jun 2018 11:24:07 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20"No=20default=20engine?= =?UTF-8?q?=20was=20specified=20and=20no=20extension=20was=20provided"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- core/server/web/middleware/error-handler.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/server/web/middleware/error-handler.js b/core/server/web/middleware/error-handler.js index c12bd96ba5..fcff8f6790 100644 --- a/core/server/web/middleware/error-handler.js +++ b/core/server/web/middleware/error-handler.js @@ -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);