Firebase database is throwing "Firebase error. Please ensure that you spelled the name of your Firebase correctly"
Asked Answered
P

5

5

I'm trying to push an object to the firebase database, but the push() method isn't working and it seems likely it has something to do with the warning I'm getting:

@firebase/database:, FIREBASE WARNING: Firebase error. Please ensure that you spelled the name of your Firebase correctly (https://<DATABASE_NAME>.firebaseio.com)

However it matches databaseURL in the config I have in the App.js

const config = {
apiKey: "<...>",
authDomain: "<...>.firebaseapp.com",
projectId: "<...>",
storageBucket: "<...>.appspot.com",
messagingSenderId: "<...>",
appId: "<...>",
databaseURL: "https://<...>.firebaseio.com",
};
firebase.initializeApp(config);

The method I use to get access to the database:

 const { currentUser } = firebase.auth();
 console.log(currentUser.uid); // works fine
 firebase
     .database()
     .ref(`/users/${currentUser.uid}/cards`)
     .push({some object})

I'm using Database location: Belgium (europe-west1) if that matters. And firebase authentication works fine.

Pioneer answered 10/1, 2021 at 17:34 Comment(3)
firebaser here Answer on how to fix this is below. But can you tell me where you got that config snippet from? I get the correct URL in my tests and if this is a bug I'd love to get it fixed.Ennui
I got the config from firebase except for the databaseURL which I added afterwards.Pioneer
Hmmm... then where did you get that specific URL value from? Thanks for answering btw, as you're not the only one to have problems here.Ennui
E
6

The databaseURL in your configuration snippet does not seem to match the actual URL of your database.

I recommend getting the correct URL from the Firebase console and putting that in the config.

Ennui answered 10/1, 2021 at 17:39 Comment(3)
It should actually end in firebasedatabase.app as far as I can tell. My experience: don't type the URL, but copy/paste it from the console link I provided.Ennui
I typed a bit too fast. The URL ended in fact with .europe-west1.firebasedatabase.appPioneer
another option is that the realtime databse wasn't created yet, go to the firebase console and make sure you created a realtime database with that nameGareth
S
1

In my case, realtime databse wasn't created yet. I faced this issue for below code on react app.

set(ref(db,'users/' + userid), {
  username:name,
  email:email,
  profile_picture: uploadLink
})

Above syntax for writing to realtime database not firestore

Scarce answered 14/12, 2022 at 7:49 Comment(0)
D
0

This error shows up when we create a database in Cloud database. Actually, we need to create a real time database which provides databaseURL.

Demodulate answered 29/7, 2021 at 11:40 Comment(1)
Yes, i forgot to create a realtime db on Firebase, tksPraemunire
K
0

In my case, I had to correct my databaseURL. or please check that you created Realtime DB in your Firebase account.

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
  databaseURL: 'https://{YOUR-PROJECT-ID}-default-rtdb.asia-southeast1.firebasedatabase.app/'
});

enter image description here

Klingel answered 20/4 at 16:19 Comment(0)
P
0

Just create an database in Realtime DataBase in Firebase.console . It will resolve the problem.

Paralysis answered 23/8 at 6:6 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Chita

© 2022 - 2024 — McMap. All rights reserved.