Skip to content

Commit 4bcbe58

Browse files
committed
Made google services string required to init firebase app.
1 parent a70ec02 commit 4bcbe58

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/server/firebase.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
21
import admin, { ServiceAccount } from 'firebase-admin'
3-
import serviceAccount from '@/../google-services.json' // Update with the path to your key
42

5-
if (!admin.apps.length) {
6-
admin.initializeApp({
7-
credential: admin.credential.cert(serviceAccount as string | ServiceAccount),
8-
})
3+
const serviceAccount = process.env.GOOGLE_SERVICES_JSON ? JSON.parse(process.env.GOOGLE_SERVICES_JSON) : null
4+
5+
if (!admin.apps.length && serviceAccount) {
6+
admin.initializeApp({
7+
credential: admin.credential.cert(serviceAccount as ServiceAccount),
8+
})
99
}
1010

1111
export const messaging = admin.messaging()

0 commit comments

Comments
 (0)