Merge pull request #2612 from overleaf/bg-precompile-web-views-only

only precompile views for web, not web-api

GitOrigin-RevId: 292f4d5dd6f81b1928ccd543898dfa643f1e5be8
This commit is contained in:
Brian Gough 2020-02-26 10:51:45 +00:00 committed by Copybot
parent 2686f5e72a
commit ac5d688d8c

View file

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