File tree Expand file tree Collapse file tree 3 files changed +44
-6
lines changed Expand file tree Collapse file tree 3 files changed +44
-6
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,10 @@ import type { FirebaseApp, FirebaseOptions } from '@firebase/app-types'
1313import type { AppOptions , App as FirebaseAdminApp } from 'firebase-admin/app'
1414import { markRaw } from 'vue'
1515import { consola } from 'consola'
16- import { VueFireNuxtModuleOptions } from './module/options'
16+ import {
17+ VueFireNuxtModuleOptions ,
18+ VueFireNuxtModuleOptionsResolved ,
19+ } from './module/options'
1720import { FirebaseEmulatorsToEnable , detectEmulators } from './module/emulators'
1821
1922const logger = consola . withTag ( 'nuxt-vuefire module' )
@@ -280,6 +283,17 @@ interface VueFireRuntimeConfig {
280283 * @internal
281284 */
282285 vuefireAdminOptions ?: Omit < AppOptions , 'credential' >
286+
287+ /**
288+ * Runtime config for the VueFire module.
289+ */
290+ vuefire ?: {
291+ /**
292+ * Options passed to the Nuxt VueFire module
293+ * @internal
294+ */
295+ options ?: VueFireNuxtModuleOptionsResolved
296+ }
283297}
284298
285299interface VueFirePublicRuntimeConfig {
Original file line number Diff line number Diff line change @@ -54,9 +54,28 @@ export interface VueFireNuxtModuleOptions {
5454 emulators ?:
5555 | boolean
5656 | {
57+ /**
58+ * Enables the emulators.
59+ */
60+ enabled ?: boolean
61+
5762 /**
5863 * The host for the Firestore emulator. Defaults to `localhost`.
5964 */
6065 host ?: string
66+
67+ auth ?: {
68+ /**
69+ * Pass options to `firebase/auth`'s `connectAuthEmulator()`.
70+ */
71+ options ?: Parameters <
72+ typeof import ( 'firebase/auth' ) . connectAuthEmulator
73+ > [ 2 ]
74+ }
6175 }
6276}
77+
78+ export interface VueFireNuxtModuleOptionsResolved
79+ extends Omit < VueFireNuxtModuleOptions , 'emulators' > {
80+ emulators : Exclude < VueFireNuxtModuleOptions [ 'emulators' ] , boolean >
81+ }
Original file line number Diff line number Diff line change 11import { connectAuthEmulator , getAuth } from 'firebase/auth'
22import type { FirebaseApp } from 'firebase/app'
33import { logger } from '../logging'
4- import { defineNuxtPlugin , useRuntimeConfig } from '#app'
4+ import { defineNuxtPlugin , useRuntimeConfig , useAppConfig } from '#app'
55
66/**
77 * Setups the auth Emulators
@@ -13,18 +13,23 @@ export default defineNuxtPlugin((nuxtApp) => {
1313 }
1414
1515 const {
16- public : { vuefire } ,
16+ vuefire,
17+ public : { vuefire : publicVuefire } ,
1718 } = useRuntimeConfig ( )
1819
19- const host = vuefire ?. emulators ?. auth ?. host
20- const port = vuefire ?. emulators ?. auth ?. port
20+ const host = publicVuefire ?. emulators ?. auth ?. host
21+ const port = publicVuefire ?. emulators ?. auth ?. port
2122
2223 if ( ! host || ! port ) {
2324 logger . warn ( 'Auth emulator not connected, missing host or port' )
2425 return
2526 }
2627
27- connectAuthEmulator ( getAuth ( firebaseApp ) , `http://${ host } :${ port } ` )
28+ connectAuthEmulator (
29+ getAuth ( firebaseApp ) ,
30+ `http://${ host } :${ port } ` ,
31+ vuefire ?. options ?. emulators ?. auth ?. options
32+ )
2833 logger . info ( `Auth emulator connected to http://${ host } :${ port } ` )
2934 connectedEmulators . set ( firebaseApp , true )
3035} )
You can’t perform that action at this time.
0 commit comments