I have an app which heavily rely on firebase remote config, on localhost there is not issue but once the app gets deployed I'm getting an error while trying to fetch remote config data. I get following error in network tab:
"Service account object must contain a string \"project_id\" property."
Event tho project_id property is declared (as string not .env variable) in service-account.json object.
I'm initializing firebase like this:
const serviceAccount = await useStorage('assets:server').getItem('service-account.json')
if (!serviceAccount)
throw new Error('service-account.json not found')
export const app = initializeApp({
credential: cert(serviceAccount as object),
})
export const firestore = getFirestore(app)
export const auth = getAuth(app)
export const remoteConfig = getRemoteConfig(app)
What I found really weird is that it worked few deploys ago and since then I haven't really touched anything regarding remote config or firebase itself. I've tried some downgrading of nuxt since I'm using their useStorage composable but that didn't work as I hoped in those last few deploys there wasn't really antything related to firebase just some UI updated.
I'm starting to get hopeless getting stuck with this over multiple days unable to find any solution with almost impossible way to debug this so I would really appreciate any idea to fix this.
Tried to log the service account right before passing to cert and it loads all content from the file and the project_id is also there as well as all other properties which are specified in firebase console. Since on localhost it works as it should I'm trying some minor changes and commiting them to opened PR on GH which redeploys it also probably good to mention that deploys are done via vercel.
I tried to add content of service-account.json directly to file where I initialize the firebaseApp instead of loading it from assets vie useStorage and out of nowhere it works. But I can't really tell why I tried to console log both at the same time and they are identical in the console.