@@ -17,30 +17,33 @@ export default defineNuxtPlugin((nuxtApp) => {
1717
1818 // only initialize the admin sdk once
1919 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+ } )
3829 }
3930 }
4031
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+
4144 return {
4245 provide : {
43- adminApp : getApp ( ) ,
46+ adminApp,
4447 } ,
4548 }
4649} )
0 commit comments