nestjs-firebase-admin
nestjs-firebase-admin copied to clipboard
Not working with firebase 10
When updating to firebase 10, I receive errors that initializing is not working anymore.
import { FirebaseAdminModule } from '@aginix/nestjs-firebase-admin';
import { Module } from '@nestjs/common';
import { join } from 'path';
import { cert } from 'firebase-admin/app';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const serviceAccount = require(join(
__dirname,
`config/firebase-admin-${process.env.FIREBASE_ENV}.json`,
));
console.log(serviceAccount);
@Module({
imports: [
FirebaseAdminModule.forRootAsync({
useFactory: () => ({
credential: cert(serviceAccount),
}),
}),
],
})
export class FirebaseModule {}
ERROR Failed to determine project ID for Auth. Initialize the SDK with service account credentials or set project ID as an app option.
Also experiencing the same issue.
Also experiencing the same issue.
Same thing here, did you fix it?
Same for me. @n3n Would you have to time to fix this issue?
Look's like it's not maintained anymore
You need to include projectId in useFactory
FirebaseAdminModule.forRootAsync({
useFactory: () => ({
credential: admin.credential.cert({
private_key: process.env.FIREBASE_PRIVATE_KEY,
client_email: process.env.FIREBASE_CLIENT_EMAIL,
project_id: process.env.FIREBASE_PROJECT_ID,
google_cloud_project: process.env.FIREBASE_PROJECT_ID,
} as Partial<admin.ServiceAccount>),
projectId: process.env.FIREBASE_PROJECT_ID,
databaseURL: process.env.FIREBASE_DATABASE_URL,
}),
}),
@jeremytsngtsng your solution doesn't work
Problem is that this lib will install its own firebase-admin package (v9). To avoid it, add to your package.json
"resolutions": {
"firebase-admin": "^11.3.0"
},
"resolutions": {
"firebase-admin": "^11.3.0"
},
@younes0 this is works so perfectly! You saved me, Thank you 👍