Skip to content

AngularFireModule.initializeApp not using configuration #1281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
codercatdev opened this issue Oct 18, 2017 · 6 comments
Closed

AngularFireModule.initializeApp not using configuration #1281

codercatdev opened this issue Oct 18, 2017 · 6 comments

Comments

@codercatdev
Copy link

Version info

Angular:
4.4.3

Firebase:
4.5.0

AngularFire:
5.0.0-rc.2

Other (e.g. Ionic/Cordova, Node, browser, operating system):
nahollmo37714n:drinkpublic.com gap4$ ionic info

cli packages: (/Users/gap4/Documents/WEB/drinkpublic.com/node_modules)

@ionic/cli-utils  : 1.13.0
ionic (Ionic CLI) : 3.13.0

global packages:

cordova (Cordova CLI) : 7.0.1

local packages:

@ionic/app-scripts : 3.0.0-201710161925
Cordova Platforms  : none
Ionic Framework    : ionic-angular 3.7.1-201710060319

System:

Android SDK Tools : 26.0.2
ios-deploy        : 1.9.1
Node              : v6.11.4
npm               : 5.4.2
OS                : macOS Sierra
Xcode             : Xcode 9.0 Build version 9A235

How to reproduce these conditions

Manual configuration is not taking affect when setting it up through
AngularFireModule.initializeApp(ENV.firebase)

It seems to only pull in .src/environments/environment.ts file

Steps to set up and reproduce

Sample data and security rules

Open

Debug output

** Errors in the JavaScript console **

** Output from firebase.database().enableLogging(true); **

** Screenshots **

Expected behavior

Should be using my development firebase conig.

Actual behavior

Wrong firebase config is provided (my production config)

@davideast
Copy link
Collaborator

@Ajonp Thanks for taking the time to post an issue.

Can you show the code for the error? Also if you could create a stackblitz or repo of this that would be great.

@codercatdev
Copy link
Author

Okay setup a repo (put it together fast hope it works).
https://github.com/ajonp/angularfire2-env-issue

After clone.

Make sure you have firebase CLI installed npm install -g firebase-tools

-npm install npm run build ionic:build:dev:prod

firebase serve Go to localhost:5000 -> should log you into environment-sample-dev.firebaseapp.com

Example Site
https://environment-sample-dev.firebaseapp.com/

image

In the picture you can see that it should be allowing environment-sample-dev based on the configuration being used. However it seems to use the ./src/environment/enivronment.ts file instead. This pushes it over to environment-sample-prod which is the wrong envirnoment

Error in the console then states
image

@codercatdev
Copy link
Author

Also if you run locally you can see that it is requesting the wrong environment
image

@codercatdev
Copy link
Author

This was related to AOT compiler. When the module loads it is based on an original config and then changes after webpack runs.

@snakenstein
Copy link

@Ajonp how did you fix that? I have the same problem with AOT compiler and webpack.

@codercatdev
Copy link
Author

@snakenstein the repo has a full working example now of how to fix. This is using ionic3 but same applies to any aot compliler setup.
https://github.com/ajonp/angularfire2-env-issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants