react-gatsby-firebase-authentication
react-gatsby-firebase-authentication copied to clipboard
Firebase App named '[DEFAULT]' already exists (app/duplicate-app).
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
@arhoy Did you find a solution ? I am facing the same issue.
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?
It works on-the-shelf if you put the credentials in .env
I am experiencing the same problem with Firebase and Gatsby, not just this package. I would guess it has something to do with versioning.