Skip to content

Commit

Permalink
Fix service account for firebase prod. (#8422)
Browse files Browse the repository at this point in the history
Co-authored-by: Sarah Rainsberger <[email protected]>
  • Loading branch information
leoxs22 and sarah11918 authored Jun 14, 2024
1 parent 98d166a commit 6161021
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/content/docs/en/guides/backend/google-firebase.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,19 @@ const serviceAccount = {
client_x509_cert_url: import.meta.env.FIREBASE_CLIENT_CERT_URL,
};

export const app = activeApps.length === 0 ? initializeApp({
credential: cert(serviceAccount as ServiceAccount),
}) : activeApps[0];
const initApp = () => {
if (import.meta.env.PROD) {
console.info('PROD env detected. Using default service account.')
// Use default config in firebase functions. Should be already injected in the server by Firebase.
return initializeApp()
}
console.info('Loading service account from env.')
return initializeApp({
credential: cert(serviceAccount as ServiceAccount)
})
}

export const app = activeApps.length === 0 ? initApp() : activeApps[0];
```

:::note
Expand Down

0 comments on commit 6161021

Please sign in to comment.