firebase / firebase-admin-node

Firebase Admin Node.js SDK
https://firebase.google.com/docs/admin/setup
Apache License 2.0
1.6k stars 357 forks source link

Unsupported Realtime Database URL - FIREBASE FATAL ERROR: Cannot parse Firebase url #2589

Open Yiming075 opened 3 weeks ago

Yiming075 commented 3 weeks ago

[READ] Step 1: Are you in the right place?

[REQUIRED] Step 2: Describe your environment

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

I follow this tutorial to set up the Hosting, Cloud Functions, and Realtime Database. https://developers.home.google.com/codelabs/smarthome-washer#1 After deployment, I visited the site and got this error from the console.

Uncaught Error: FIREBASE FATAL ERROR: Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com at st (util.ts:172:9) at Qt (parser.ts:88:5) at Oi.databaseFromApp (RepoManager.ts:108:21) at Qi.INTERNAL.registerComponent.z.setServiceProps.Reference [as instanceFactory] (index.ts:52:42) at S.getOrInitializeService (provider.ts:190:33) at S.getImmediate (provider.ts:95:29) at q._getService (firebaseApp.ts:127:54) at c.<computed> [as database] (firebaseNamespaceCore.ts:228:29) at Object.i [as database] (firebaseNamespaceCore.ts:209:32) at SmartHome.handleData (main.js:70:12)

I found that it is caused by const parsedUrl = parseDatabaseURL(dataURL) in parser.ts, it doesn't support the URL with 4 parts. Firebase projects with Realtime Database in us-central1 region work fine (3 parts) https://x.firebaseio.com But other regions don't work (4 parts) https://x.asia-southeast1.firebasedatabase.app

This is the code causing the error, I didn't modify it much from the example given in the tutorial firebase.database().ref('/').child('washer').on("value", (snapshot) => { ...

google-oss-bot commented 3 weeks ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.