From e1bec79db9c972ac9bd9edf0e9cdc58934603727 Mon Sep 17 00:00:00 2001 From: Yannis Barlas <yannisbarlas@gmail.com> Date: Tue, 8 Dec 2020 17:12:51 +0200 Subject: [PATCH] feat(server): add env variable that will serve build --- src/app.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/app.js b/src/app.js index 7d796e4..3c83b95 100644 --- a/src/app.js +++ b/src/app.js @@ -17,7 +17,6 @@ const logger = require('@pubsweet/logger') const registerComponents = require('pubsweet-server/src/register-components') const api = require('pubsweet-server/src/routes/api') -const index = require('pubsweet-server/src/routes/index') const configureApp = app => { const models = require('@pubsweet/models') @@ -112,14 +111,19 @@ const configureApp = app => { useGraphQLServer = false } - logger.info('useGraphQLServer', useGraphQLServer) - if (useGraphQLServer) { const gqlApi = require('./graphqlApi') gqlApi(app) // GraphQL API } - app.use('/', index) // Serve the index page for front end + if ( + config.has('pubsweet-server.serveClient') && + config.get('pubsweet-server.serveClient') + ) { + app.get('*', (req, res) => { + res.sendFile(path.join('.', '_build', 'assets', 'index.html')) + }) + } app.use((err, req, res, next) => { // Development error handler, will print stacktrace -- GitLab