@@ -52,7 +52,7 @@ export default defineNuxtModule<VueFireNuxtModuleOptions>({
5252 const templatesDir = fileURLToPath ( new URL ( '../templates' , import . meta. url ) )
5353
5454 // we need this to avoid some warnings about missing credentials and ssr
55- const hasEmulatorsEnabled = await willUseEmulators (
55+ const emulatorsConfig = await willUseEmulators (
5656 options ,
5757 resolve ( nuxt . options . rootDir , 'firebase.json' ) ,
5858 logger
@@ -98,20 +98,19 @@ export default defineNuxtModule<VueFireNuxtModuleOptions>({
9898
9999 if ( options . appCheck ) {
100100 addPlugin ( resolve ( runtimeDir , 'app-check/plugin.client' ) )
101- // TODO: ensure this is the only necessary check. Maybe we need to check if server
102- if ( hasServiceAccount || hasEmulatorsEnabled ) {
101+ // TODO: With emulators a different plugin should be used, one that doesn't instantiate app check as it will error on the server anyway
102+ if ( hasServiceAccount || emulatorsConfig ) {
103103 // this is needed by the api endpoint to properly work if no service account is provided, otherwise, the projectId is within the service account
104104 addPlugin ( resolve ( runtimeDir , 'app-check/plugin.server' ) )
105- } else if ( nuxt . options . ssr && ! hasEmulatorsEnabled ) {
105+ } else if ( nuxt . options . ssr && ! emulatorsConfig ) {
106106 logger . warn (
107107 'You activated both SSR and app-check but you are not providing a service account for the admin SDK. See https://vuefire.vuejs.org/nuxt/getting-started.html#configuring-the-admin-sdk.'
108108 )
109109 }
110110 }
111111
112112 if ( options . auth ) {
113- // TODO: should be fine if emulators are activated
114- if ( nuxt . options . ssr && ! hasServiceAccount && ! hasEmulatorsEnabled ) {
113+ if ( nuxt . options . ssr && ! hasServiceAccount && ! emulatorsConfig ) {
115114 logger . warn (
116115 'You activated both SSR and auth but you are not providing a service account for the admin SDK. See https://vuefire.vuejs.org/nuxt/getting-started.html#configuring-the-admin-sdk.'
117116 )
@@ -130,7 +129,7 @@ export default defineNuxtModule<VueFireNuxtModuleOptions>({
130129 if (
131130 options . auth &&
132131 nuxt . options . ssr &&
133- ( hasServiceAccount || hasEmulatorsEnabled )
132+ ( hasServiceAccount || emulatorsConfig )
134133 ) {
135134 // Add the session handler than mints a cookie for the user
136135 addServerHandler ( {
@@ -163,8 +162,8 @@ export default defineNuxtModule<VueFireNuxtModuleOptions>({
163162
164163 // Emulators must be enabled after the app is initialized but before some APIs like auth.signinWithCustomToken() are called
165164
166- if ( hasEmulatorsEnabled ) {
167- const emulators = detectEmulators ( options , hasEmulatorsEnabled , logger )
165+ if ( emulatorsConfig ) {
166+ const emulators = detectEmulators ( options , emulatorsConfig , logger )
168167
169168 // expose the detected emulators to the plugins
170169 nuxt . options . runtimeConfig . public . vuefire ??= { }
@@ -195,7 +194,7 @@ export default defineNuxtModule<VueFireNuxtModuleOptions>({
195194 )
196195 }
197196
198- if ( hasServiceAccount || hasEmulatorsEnabled ) {
197+ if ( hasServiceAccount || emulatorsConfig ) {
199198 if ( options . auth ) {
200199 // decodes user token from cookie if any
201200 addPlugin ( resolve ( runtimeDir , 'auth/plugin-user-token.server' ) )
@@ -205,7 +204,7 @@ export default defineNuxtModule<VueFireNuxtModuleOptions>({
205204 addPlugin ( resolve ( runtimeDir , 'admin/plugin.server' ) )
206205
207206 // We need the projectId to be explicitly set for the admin SDK to work
208- if ( hasEmulatorsEnabled ) {
207+ if ( emulatorsConfig ) {
209208 options . admin ??= { }
210209 options . admin . options ??= { }
211210 options . admin . options . projectId ??= options . config . projectId
0 commit comments