Skip to content

Commit 7ffdbce

Browse files
committed
fix(emulator): ensure projectId with Emulators
1 parent 66bd12c commit 7ffdbce

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

packages/nuxt/src/module.ts

+14-9
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,13 @@ export default defineNuxtModule<VueFireNuxtModuleOptions>({
9999
if (options.appCheck) {
100100
addPlugin(resolve(runtimeDir, 'app-check/plugin.client'))
101101
// TODO: ensure this is the only necessary check. Maybe we need to check if server
102-
if (!hasEmulatorsEnabled) {
103-
if (hasServiceAccount) {
104-
// this is needed by the api endpoint to properly work if no service account is provided, otherwise, the projectId is within the service account
105-
addPlugin(resolve(runtimeDir, 'app-check/plugin.server'))
106-
} else if (nuxt.options.ssr) {
107-
logger.warn(
108-
'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.'
109-
)
110-
}
102+
if (hasServiceAccount || hasEmulatorsEnabled) {
103+
// this is needed by the api endpoint to properly work if no service account is provided, otherwise, the projectId is within the service account
104+
addPlugin(resolve(runtimeDir, 'app-check/plugin.server'))
105+
} else if (nuxt.options.ssr && !hasEmulatorsEnabled) {
106+
logger.warn(
107+
'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.'
108+
)
111109
}
112110
}
113111

@@ -205,6 +203,13 @@ export default defineNuxtModule<VueFireNuxtModuleOptions>({
205203

206204
// injects firebaseAdminApp
207205
addPlugin(resolve(runtimeDir, 'admin/plugin.server'))
206+
207+
// We need the projectId to be explicitly set for the admin SDK to work
208+
if (hasEmulatorsEnabled) {
209+
options.admin ??= {}
210+
options.admin.options ??= {}
211+
options.admin.options.projectId ??= options.config.projectId
212+
}
208213
}
209214
}
210215

0 commit comments

Comments
 (0)