Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Dynamic loading of configuration to initialize firebase #3056

Unanswered
PhantomLinker asked this question in Q&A
Discussion options

For better CI/CD I am trying to load the firebase configuration from an external source before bootstrapping the app.module.ts. I tried many solutions which were suggested by others, e.g.: the solution suggested by @efraespada in #1095 or this guide by sakshi subedi but I couldn't get them to work on my end.

Also the APP_INITIALIZER does not work, as the providers don't block the execution of the imports.

Being able to use useFactory as suggested in #2451 might solve this issue by allowing something like this:

 {
 provide: FIREBASE_OPTIONS,
 useFactory: loadFirebaseConfigFromExternalSource,
}

But with the initialisation of angularfire since V7 an approach like this would be even better:

@NgModule({
 declarations: [
 AppComponent
 ],
 imports: [
 ...
 provideFirebaseApp( async () => {
 const fb_config = await loadFirebaseConfigFromExternalSource();
 return initializeApp(fb_config);
 }),
 provideFirestore(() => getFirestore()),
 ...
 ],
...

So is there a way to load the firebase config via a http get before initialising the app? If not, would it be possible to include such a feature by also handling () => Promise<FirebaseApp> instead of only () => FirebaseApp in provideFirebaseApp?

Thanks in advance

You must be logged in to vote

Replies: 1 comment 1 reply

Comment options

I am having a similar situation, did you manage to find a solution to it ?

You must be logged in to vote
1 reply
Comment options

Hi,
Sorry for the late reply. I just saw your comment. Yes, I did manage to find a solution. I simply switched to the official firebase package: https://www.npmjs.com/package/firebase

This package does not require any import of firebase in the app.module.ts and has a different initialization approach. It's harder to use than angularfire but it's also more flexible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /