reactjsfirebasefirebase-realtime-database

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


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.


Solution

  • 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.