@@ -17,30 +17,33 @@ export default defineNuxtPlugin((nuxtApp) => {
17
17
18
18
// only initialize the admin sdk once
19
19
if ( ! getApps ( ) . length ) {
20
- const adminApp =
21
- // this is specified when deployed on Firebase and automatically picks up the credentials from env variables
22
- process . env . GCLOUD_PROJECT
23
- ? initializeApp ( )
24
- : initializeApp ( {
25
- ...firebaseAdmin . config ,
26
- credential : cert ( firebaseAdmin . serviceAccount ) ,
27
- } )
28
-
29
- if ( vuefireOptions . appCheck ) {
30
- // NOTE: necessary in VueFireAppCheckServer
31
- if ( ! firebaseApp . options . appId ) {
32
- throw new Error (
33
- '[VueFire]: Missing "appId" in firebase config. This is necessary to use the app-check module on the server.'
34
- )
35
- }
36
-
37
- VueFireAppCheckServer ( adminApp , firebaseApp )
20
+ // this is specified when deployed on Firebase and automatically picks up the credentials from env variables
21
+ if ( process . env . GCLOUD_PROJECT ) {
22
+ initializeApp ( )
23
+ } else {
24
+ initializeApp ( {
25
+ // TODO: is this really going to be used?
26
+ ...firebaseAdmin . config ,
27
+ credential : cert ( firebaseAdmin . serviceAccount ) ,
28
+ } )
38
29
}
39
30
}
40
31
32
+ const adminApp = getApp ( )
33
+ if ( vuefireOptions . appCheck ) {
34
+ // NOTE: necessary in VueFireAppCheckServer
35
+ if ( ! firebaseApp . options . appId ) {
36
+ throw new Error (
37
+ '[VueFire]: Missing "appId" in firebase config. This is necessary to use the app-check module on the server.'
38
+ )
39
+ }
40
+
41
+ VueFireAppCheckServer ( adminApp , firebaseApp )
42
+ }
43
+
41
44
return {
42
45
provide : {
43
- adminApp : getApp ( ) ,
46
+ adminApp,
44
47
} ,
45
48
}
46
49
} )
0 commit comments