firebase / firebase/firebase-tools
firebase serve inconsistently adds appId to /__/firebase/init.js
- Dominant language
- TypeScript
- Stars
- 4.5k
- Forks
- 1.3k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 84
Description
### [REQUIRED] Environment info
**firebase-tools:** 7.12.1
**Platform:** macOS and Windows (both on 7.12.1)
### [REQUIRED] Test case
Reproducing is inconsistent. However, I encountered this using the [Messaging quickstart](https://github.com/firebase/quickstart-js/tree/master/messaging#getting-started) with [this index.html file](https://gist.github.com/katowulf/7089ddd2cd47fdb6fac468fd0f1313d5).
I can share the demo project if you want to repro locally.
### [REQUIRED] Steps to reproduce
`git clone https://github.com/firebase/quickstart-js.git`
`cd quickstart-js/messaging`
`firebase serve -p 8081`
open https://localhost:8081/__/firebase/init.js
Note that the appId is not present.
Try visiting https://localhost:8081 and note the JS errors (quickstart won't run)
This was reproducible in several projects in different states (with only one web app, with multiple web apps, old projects and newly created ones, multiple accounts). It's consistent for any given app, but inconsistent in which apps work.
Also important to note, the apps DO HAVE an `appId` when viewed in the console:

### [REQUIRED] Expected behavior
The `init.js` file should contain `appId`.
### [REQUIRED] Actual behavior
The `init.js` file contains something similar to the following:
```
if (typeof firebase === 'undefined') throw new Error('hosting/init-error: Firebase SDK not detected. You must include it before /__/firebase/init.js');
var firebaseConfig = {
"projectId": "kato-...",
"databaseURL": "https://kato-...io.com",
"storageBucket": "kato-...ot.com",
"locationId": "us-central",
"apiKey": "AIza...ePs",
"authDomain": "kato-...app.com",
"messagingSenderId": "83...95"
};
if (firebaseConfig) {
firebase.initializeApp(firebaseConfig);
}
```
Contributor guide
Assessment
This issue has not been assessed yet.