LoginSignup
4
1

More than 3 years have passed since last update.

firebase.initializeApp() に必要な config 情報に appId がいつの間にか追加されていた

Last updated at Posted at 2019-11-21

経緯

firebase.initializeApp() に必要な config の確認を行おうとしたところ、
確認の仕方が以前と少し変わっていました。

結果としては「ウェブアプリ用の設定スニペットを入手する」のドキュメントに沿う形で、
「アプリを追加」という項目から「ウェブアプリにfirebaseを追加」という手順を進めると config 情報が確認できたのですが、もう既に firebase で ウェブアプリを公開していたので「アプリを追加」という項目に戸惑ってしまいました。

また表示された config 情報には appId という項目が増えていました。
現在 appId 無しの config で firebase.initializeApp() して問題なく動いているので、
そこもまた謎なので調べてみました。

FirebaseConfig
const config = {
  apiKey: "xxxxxxxxxxxxxx",
  authDomain: "xxxxx.firebaseapp.com",
  databaseURL: "https://xxxxx.firebaseio.com",
  projectId: "xxxxxxxxxxxx",
  storageBucket: "xxxxxx.appspot.com",
  messagingSenderId: "xxxxxxxxxxxxx",
  // appId: xxxxxxxxxxxxxxxxxx(新しく増えていた項目)
};

取り敢えず分かった事

  • 以前ウェブアプリの config の中には appId は無かった(後から追加されたもの)
  • appId は無くても動くが、firebase 関連のサービスの中には appId が必須なものがある
  • 現在 firebase でウェブアプリを公開する手順として「アプリの登録」という手順を踏む。以前だとその様な手順が無かったために、既に deploy 済みであるウェブアプリは「アプリの登録」がなされていないステータスになってる(アプリの追加(登録)を行う事で appId を含む config 情報を確認できる)

参考情報について

firebase の公式ドキュメントを漁りましたが、いつ頃 appId が config 情報に含まれる様になったかは記載を見つけられませんでした。firebase を使ったウェブサイトの hosting 関連記事について、幾つかの古い記事、新しい記事の比較に基づいた結論です。

stack_overflow でも似たような質問が一つ見受けられました。

4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1