From a100b6ba705e575cb200833fdf9ba8818861786f Mon Sep 17 00:00:00 2001
From: Yannis Barlas <yannisbarlas@gmail.com>
Date: Mon, 23 Nov 2020 21:49:11 +0200
Subject: [PATCH] fix(server): handle client protocol and port not being
 defined

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

diff --git a/src/app.js b/src/app.js
index 092e8c8..7d796e4 100644
--- a/src/app.js
+++ b/src/app.js
@@ -59,9 +59,15 @@ const configureApp = app => {
 
   // Allow CORS from client if host / port is different
   if (config.has('pubsweet-client.host')) {
-    const clientProtocol = config.get('pubsweet-client.protocol') || 'http'
+    const clientProtocol =
+      (config.has('pubsweet-client.protocol') &&
+        config.get('pubsweet-client.protocol')) ||
+      'http'
+
     let clientHost = config.get('pubsweet-client.host')
-    const clientPort = config.get('pubsweet-client.port')
+
+    const clientPort =
+      config.has('pubsweet-client.port') && config.get('pubsweet-client.port')
 
     // This is here because webpack dev server might need to be started with
     // 0.0.0.0 instead of localhost, but the incoming request will still be
-- 
GitLab