Open christhompsongoogle opened 1 year ago
Potentially also running into this with next-firebase-auth it seems (although it happens when upgrading firebase
and not firebase-tools
)
@Geoffrey-Pliez,
I'm from the Firebase Web SDK team. I was looking a bit into this issue and I'm trying to reproduce this here to see if this was a Firebase Web Frameworks issue or a Firebase Admin SDK issue.
I haven't been able to get this to work with the latest or older versions of the firebase-admin
and firebase-tools
SDKs. All versions seem to have problems at the build step (the same error as you reported) which is fixed by initializing the firebase-admin
SDK as described here.
I should note that I was able to reproduce this issue without Firebase Web Framework support (from firebase-tools) simply by creating an Astro app from scratch. I went through these steps:
npm create astro@latest
and walking through the configuration steps.npm install firestore-admin
.index.astro
from:---
import Layout from '../layouts/Layout.astro';
import Card from '../components/Card.astro';
---
to:
---
import Layout from '../layouts/Layout.astro';
import Card from '../components/Card.astro';
import { getFirestore } from 'firebase-admin/firestore'
const firestore = getFirestore()
---
npm run build
.This produces the same Error: The default Firebase app does not exist
that you reported. The error goes away if I add:
import { initializeApp } from 'firebase-admin/app'
const app = initializeApp();
Could you step me how you've setup your environment past these steps to make this work with the older admin / firebase-tools versions without calling initializeApp
first, as is the case in your provided code?
Thanks very much.
@DellaBitta
Sorry, I don't remember very well because currently I work around the problem by initializing firebase-admin in Astro middleware.
As soon as I have time, I will try to investigate why it worked before for me.
Any updates on this issue? I'm facing the same error but in Next.js The default Firebase app does not exist. Make sure you call initializeApp() When I try to initializeApp() inside the API route or middleware?
Hi @aayman997,
We're still seeking a reproducible test case beyond the originally reported one, which I had already detailed how I was able to update the code to make it work. If you have a different issue and setup then please create a new issue. Thanks!
Hi Sorry, but it doesn't work. Can you please be more specific about how to work around this issue which still persists?
Hello, are there any updates on how to solve this issue? I'm using nextjs and seems to work sometimes and sometimes it doesn't
Discussed in https://github.com/firebase/firebase-tools/discussions/5910
From Geoffrey-Pliez: