Spaces:
Running
Running
Update app.js
Browse files
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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),
|