From 0b454016cf0ddaae9f87e30053ae6365eb686462 Mon Sep 17 00:00:00 2001
From: timothycarambat <rambat1010@gmail.com>
Date: Thu, 4 Apr 2024 10:47:26 -0700
Subject: [PATCH] patch comkey path to fallback

---
 collector/utils/comKey/index.js | 7 +++++--
 server/utils/comKey/index.js    | 5 ++++-
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/collector/utils/comKey/index.js b/collector/utils/comKey/index.js
index 0e96a6972..77ec1c612 100644
--- a/collector/utils/comKey/index.js
+++ b/collector/utils/comKey/index.js
@@ -1,11 +1,14 @@
 const crypto = require("crypto");
 const fs = require("fs");
 const path = require("path");
-
 const keyPath =
   process.env.NODE_ENV === "development"
     ? path.resolve(__dirname, `../../../server/storage/comkey`)
-    : path.resolve(process.env.STORAGE_DIR, `comkey`);
+    : path.resolve(
+        process.env.STORAGE_DIR ??
+          path.resolve(__dirname, `../../../server/storage`),
+        `comkey`
+      );
 
 class CommunicationKey {
   #pubKeyName = "ipc-pub.pem";
diff --git a/server/utils/comKey/index.js b/server/utils/comKey/index.js
index e545a6be5..aec436bbd 100644
--- a/server/utils/comKey/index.js
+++ b/server/utils/comKey/index.js
@@ -4,7 +4,10 @@ const path = require("path");
 const keyPath =
   process.env.NODE_ENV === "development"
     ? path.resolve(__dirname, `../../storage/comkey`)
-    : path.resolve(process.env.STORAGE_DIR, `comkey`);
+    : path.resolve(
+        process.env.STORAGE_DIR ?? path.resolve(__dirname, `../../storage`),
+        `comkey`
+      );
 
 // What does this class do?
 // This class generates a hashed version of some text (typically a JSON payload) using a rolling RSA key