Skip to content
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

Firebase App named '[DEFAULT]' already exists (app/duplicate-app). #54

Open
arhoy opened this issue Oct 2, 2019 · 4 comments
Open

Firebase App named '[DEFAULT]' already exists (app/duplicate-app). #54

arhoy opened this issue Oct 2, 2019 · 4 comments

Comments

@arhoy
Copy link

arhoy commented Oct 2, 2019

HI, I have done the steps below but run into the following error when I try to sign in or register.

Firebase: Firebase App named '[DEFAULT]' already exists (app/duplicate-app).
▶ 2 stack frames were collapsed.
new Firebase
C:/Users/arhoy/OneDrive/Desktop/web-development/playground/gatsby/react-gatsby-firebase-authentication/src/components/Firebase/firebase.js:76
  73 |            }
  74 | 
  75 |            // merge auth and db user
> 76 |            authUser = {
  77 |              uid: authUser.uid,
  78 |              email: authUser.email,
  79 |              emailVerified: authUser.emailVerified,
View compiled
getFirebase
C:/Users/arhoy/OneDrive/Desktop/web-development/playground/gatsby/react-gatsby-firebase-authentication/src/components/Firebase/firebase.js:104
  101 |   messages = () => this.db.ref('messages');
  102 | }
  103 | 
> 104 | let firebase;
  105 | 
  106 | function getFirebase(app, auth, database) {
  107 |   if (!firebase) {
View compiled
(anonymous function)
C:/Users/arhoy/OneDrive/Desktop/web-development/playground/gatsby/react-gatsby-firebase-authentication/src/components/layout.js:1
> 1 | import React, { Component, Fragment } from 'react';
  2 | 
  3 | import Navigation from './Navigation';
  4 | import getFirebase, { FirebaseContext } from './Firebase';

I am not sure what I am doing wrong, I have set up my ENV variables from Firebase and all that.

Thank you

@smrutiparida
Copy link

@arhoy Did you find a solution ? I am facing the same issue.

@gkartalis
Copy link

I had the same problem.

I created two files with the firebase credentials for prod/dev

  • .env.development
  • .env.production

I run gatsby develop and the app crashed with the previous error.

If you open the gatsby-config file you will see that it has this code in it

require("dotenv").config({
  path: `.env.${process.env.NODE_ENV}`,
})

That means that you have to pass a NODE_ENV before the gatsby develop command like that:

NODE_ENV=development gatsby develop (for development)
NODE_ENV=production gatsby develop (for production)

In this way, it takes the NODE_ENV variable that you pass and it uses the correct env variables from .env.* files.

I believe that you can close the issue or maybe we can update the documentation accordingly to make it more clear?

@guhur
Copy link

guhur commented Jun 14, 2020

It works on-the-shelf if you put the credentials in .env

@marharyta
Copy link

I am experiencing the same problem with Firebase and Gatsby, not just this package. I would guess it has something to do with versioning.

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

5 participants