diff --git a/services/web/app/src/infrastructure/Server.js b/services/web/app/src/infrastructure/Server.js index 324f71cc71..239aeddad8 100644 --- a/services/web/app/src/infrastructure/Server.js +++ b/services/web/app/src/infrastructure/Server.js @@ -173,12 +173,6 @@ expressLocals(webRouter, privateApiRouter, publicApiRouter) webRouter.use(SessionAutostartMiddleware.invokeCallbackMiddleware) -if (app.get('env') === 'production') { - logger.info('Production Enviroment') - app.enable('view cache') - Views.precompileViews(app) -} - webRouter.use(function(req, res, next) { if (Settings.siteIsOpen) { next() @@ -240,6 +234,11 @@ const enableWebRouter = if (enableWebRouter || notDefined(enableWebRouter)) { logger.info('providing web router') + if (app.get('env') === 'production') { + logger.info('precompiling views for web in production environment') + Views.precompileViews(app) + } + app.use(publicApiRouter) // public API goes with web router for public access app.use(Validation.errorMiddleware) app.use(HttpErrorController.handleError)