Home > Enterprise >  FIREBASE FATAL ERROR: Can't determine Firebase Database URL
FIREBASE FATAL ERROR: Can't determine Firebase Database URL

Time:09-02

I deployed a React app, but I'm receiving the error message:

@firebase/database: FIREBASE FATAL ERROR: Can't determine Firebase Database URL. Be sure to include a Project ID when calling firebase.initializeApp().

How do I fix this issue?

My firebase.js file currently looks like this...

import firebase from "firebase";

firebase.initializeApp({
  apiKey: process.env.REACT_APP_FIREBASE_API_KEY,
  authDomain: process.env.REACT_APP_FIREBASE_AUTH_DOMAIN,
  projectId: process.env.REACT_APP_FIREBASE_PROJECT_ID,
  storageBucket: process.env.REACT_APP_FIREBASE_STORAGE_BUCKET,
  messagingSenderId: process.env.REACT_APP_FIREBASE_MESSAGING_SENDER_ID,
  appId: process.env.REACT_APP_FIREBASE_APP_ID,
});

const database = firebase.database();
export const auth = firebase.auth();

export default database;

My .env.local file looks like this (I redacted full details)

REACT_APP_FIREBASE_API_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXmRv4

REACT_APP_FIREBASE_AUTH_DOMAIN=XXXXXXXXXXXXXXXXXXXXXXXXXd99c.firebaseapp.com

REACT_APP_FIREBASE_PROJECT_ID=XXXXXXXXXXXXXXXXXXXXXXXXXproject-fd99c

REACT_APP_FIREBASE_STORAGE_BUCKET=XXXXXXXXXXXXXXXXXXXXXXXXXd99c.appspot.com

REACT_APP_FIREBASE_MESSAGING_SENDER_ID=XXXXXXXXXXXXXXXXXXXXXXXXX706

REACT_APP_FIREBASE_APP_ID=XXXXXXXXXXXXXXXXXXXXXXXXX54da93

CodePudding user response:

Your configuration object (the one you pass to initializeApp) is missing a databaseURL property. It's unclear from your question why it's missing or what you may have done to omit it, but that's what you need. You can get the string value for that property in the Firebase console for your app under "project settings".

  • Related