From c6c07e46141156a39c7e875223798303ea70e776 Mon Sep 17 00:00:00 2001
From: Yannis Barlas <yannisbarlas@gmail.com>
Date: Wed, 8 Apr 2020 21:56:21 +0300
Subject: [PATCH] fix(server): fix crash when trying to read empty config
 values

---
 src/app.js | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/src/app.js b/src/app.js
index 39a12e9..2481b23 100644
--- a/src/app.js
+++ b/src/app.js
@@ -57,14 +57,19 @@ const configureApp = app => {
   }
 
   // Allow CORS from client if host / port is different
-  app.use(
-    cors({
-      origin: `${config.get('pubsweet-client.host')}:${config.get(
-        'pubsweet-client.port',
-      )}`,
-      credentials: true,
-    }),
-  )
+  if (
+    config.has('pubsweet-client.host') &&
+    config.has('pubsweet-client.port')
+  ) {
+    app.use(
+      cors({
+        origin: `${config.get('pubsweet-client.host')}:${config.get(
+          'pubsweet-client.port',
+        )}`,
+        credentials: true,
+      }),
+    )
+  }
 
   // Register passport authentication strategies
   app.use(passport.initialize())
-- 
GitLab