From ed8fb40b63980d13e3ce62d072d6e7631f8ea10d Mon Sep 17 00:00:00 2001 From: David Luzar Date: Thu, 9 Dec 2021 13:24:41 +0100 Subject: [PATCH] fix: make firebase config parsing not fail on undefined env (#4381) --- src/excalidraw-app/data/firebase.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/excalidraw-app/data/firebase.ts b/src/excalidraw-app/data/firebase.ts index dd7e207ea..bf4dbb7fd 100644 --- a/src/excalidraw-app/data/firebase.ts +++ b/src/excalidraw-app/data/firebase.ts @@ -11,7 +11,15 @@ import { MIME_TYPES } from "../../constants"; // private // ----------------------------------------------------------------------------- -const FIREBASE_CONFIG = JSON.parse(process.env.REACT_APP_FIREBASE_CONFIG); +let FIREBASE_CONFIG: Record; +try { + FIREBASE_CONFIG = JSON.parse(process.env.REACT_APP_FIREBASE_CONFIG); +} catch (error: any) { + console.warn( + `Error JSON parsing firebase config. Supplied value: ${process.env.REACT_APP_FIREBASE_CONFIG}`, + ); + FIREBASE_CONFIG = {}; +} let firebasePromise: Promise | null = null;