Skip to content
Snippets Groups Projects
Commit e1bec79d authored by Yannis Barlas's avatar Yannis Barlas
Browse files

feat(server): add env variable that will serve build

parent d920a0b6
No related branches found
No related tags found
No related merge requests found
...@@ -17,7 +17,6 @@ const logger = require('@pubsweet/logger') ...@@ -17,7 +17,6 @@ const logger = require('@pubsweet/logger')
const registerComponents = require('pubsweet-server/src/register-components') const registerComponents = require('pubsweet-server/src/register-components')
const api = require('pubsweet-server/src/routes/api') const api = require('pubsweet-server/src/routes/api')
const index = require('pubsweet-server/src/routes/index')
const configureApp = app => { const configureApp = app => {
const models = require('@pubsweet/models') const models = require('@pubsweet/models')
...@@ -112,14 +111,19 @@ const configureApp = app => { ...@@ -112,14 +111,19 @@ const configureApp = app => {
useGraphQLServer = false useGraphQLServer = false
} }
logger.info('useGraphQLServer', useGraphQLServer)
if (useGraphQLServer) { if (useGraphQLServer) {
const gqlApi = require('./graphqlApi') const gqlApi = require('./graphqlApi')
gqlApi(app) // GraphQL API 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) => { app.use((err, req, res, next) => {
// Development error handler, will print stacktrace // Development error handler, will print stacktrace
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment