@@ -59,18 +59,34 @@ export default defineNuxtModule<VueFireNuxtModuleOptions>({
5959 nuxt . options . appConfig . firebaseConfig = markRaw ( options . config )
6060 nuxt . options . appConfig . vuefireOptions = markRaw ( options )
6161
62- nuxt . options . runtimeConfig . vuefire = {
63- options : {
64- ...options ,
65- // ensure the resolved version easier to consume
66- emulators : {
67- enabled :
68- typeof options . emulators === 'object'
69- ? options . emulators . enabled ?? true // allows user to comment out enabled: false
70- : ! ! options . emulators ,
71- ...( typeof options . emulators === 'object' ? options . emulators : { } ) ,
72- } ,
62+ const isAuthEnabled =
63+ typeof options . auth === 'object'
64+ ? options . auth . enabled ?? true // allows user to comment out enabled: false
65+ : ! ! options . auth
66+
67+ const resolvedVueFireOptions = {
68+ ...options ,
69+ // ensure the resolved version easier to consume
70+ emulators : {
71+ enabled :
72+ typeof options . emulators === 'object'
73+ ? options . emulators . enabled ?? true // allows user to comment out enabled: false
74+ : ! ! options . emulators ,
75+ ...( typeof options . emulators === 'object' ? options . emulators : { } ) ,
7376 } ,
77+ auth : {
78+ enabled : isAuthEnabled ,
79+ // enable session cookie when auth is `true`
80+ sessionCookie :
81+ typeof options . auth === 'object'
82+ ? isAuthEnabled && options . auth . sessionCookie // deactivating auth also deactivates the session cookie
83+ : ! ! options . auth , // fallback to the boolean value of options.auth
84+ ...( typeof options . auth === 'object' ? options . auth : { } ) ,
85+ } ,
86+ } satisfies VueFireNuxtModuleOptionsResolved
87+
88+ nuxt . options . runtimeConfig . vuefire = {
89+ options : resolvedVueFireOptions ,
7490 }
7591
7692 // we need this to avoid some warnings about missing credentials and ssr
@@ -169,7 +185,11 @@ export default defineNuxtModule<VueFireNuxtModuleOptions>({
169185 )
170186 }
171187
172- if ( nuxt . options . ssr && ( hasServiceAccount || emulatorsConfig ) ) {
188+ if (
189+ nuxt . options . ssr &&
190+ ( hasServiceAccount || emulatorsConfig ) &&
191+ resolvedVueFireOptions . auth . sessionCookie
192+ ) {
173193 // Add the session handler than mints a cookie for the user
174194 addServerHandler ( {
175195 route : '/api/__session' ,
@@ -243,7 +263,7 @@ export default defineNuxtModule<VueFireNuxtModuleOptions>({
243263 }
244264
245265 if ( hasServiceAccount || emulatorsConfig ) {
246- if ( options . auth ) {
266+ if ( resolvedVueFireOptions . auth . sessionCookie ) {
247267 // decodes user token from cookie if any
248268 addPlugin ( resolve ( runtimeDir , 'auth/plugin-user-token.server' ) )
249269 }
0 commit comments