everydaycats commited on
Commit
2a1a103
·
verified ·
1 Parent(s): ef9fa39

Update app.js

Browse files
Files changed (1) hide show
  1. app.js +6 -1
app.js CHANGED
@@ -10,7 +10,12 @@ import admin from 'firebase-admin';
10
  // If you do not have 'serviceAccountKey.json', this will gracefully degrade to memory-only
11
  let db = null;
12
  try {
13
- if (fs.existsSync('./serviceAccountKey.json')) {
 
 
 
 
 
14
  const serviceAccount = JSON.parse(fs.readFileSync('./serviceAccountKey.json', 'utf8'));
15
  admin.initializeApp({
16
  credential: admin.credential.cert(serviceAccount),
 
10
  // If you do not have 'serviceAccountKey.json', this will gracefully degrade to memory-only
11
  let db = null;
12
  try {
13
+ // The env secret MUST contain the full JSON string
14
+ // exactly like the serviceAccountKey.json contents
15
+ const serviceAccount = JSON.parse(process.env.FIREBASE_SERVICE_ACCOUNT_JSON);
16
+
17
+
18
+ if (serviceAccount && serviceAccount != null) {
19
  const serviceAccount = JSON.parse(fs.readFileSync('./serviceAccountKey.json', 'utf8'));
20
  admin.initializeApp({
21
  credential: admin.credential.cert(serviceAccount),