Skip to content
Advertisement

Firebase Admin Failed to determine project ID

I have a react app and I have added firebase to it. The Sign Up creates a new user account but since the user has to be tracked I have gotten the user’s id token and added it to local storage. It then takes the user to a dashboard page with the route link “/dashboard” but anyone can go to that link without signing up, it takes the id token kept in local storage, it then uses firebase admin to verify the id. If the verification is a success, it loads the page. Else it redirects the user to the login page. However when I created a new account, I got directed to the dashboard, and then redirected back to the login page. The id token had been correctly put into the local storage and the account had been created, but I got the error
Failed to determine project ID: Error while making request: Failed to fetch. Error code: undefined at FirebaseAppError.FirebaseError [as constructor] (error.js:44) at FirebaseAppError.PrefixedFirebaseError [as constructor] (error.js:90) at new FirebaseAppError (error.js:125) at credential-internal.js:183.
Here is my code:
index.js:

JavaScript


Signup.js:

JavaScript


Dashboard.js:

JavaScript

Advertisement

Answer

Firebase-admin example initialization (it’s different from firebase client side)

JavaScript
Advertisement