LoginSignup
7
3

More than 3 years have passed since last update.

Firebase Local Emulator Suiteにネットワーク越しでアクセスする

Posted at

結論

firebase.json

"emulators": {
  "functions": {
    "host": "0.0.0.0"
  },
  "firestore": {
    "host": "0.0.0.0"
  },
  "database": {
    "host": "0.0.0.0"
  },
  "hosting": {
    "host": "0.0.0.0"
  }
}

を追加しましょう。

経緯

Firebaseによる開発を加速するためにFirebase Local Emulator Suiteを導入しました。Firebaseのローカルでの開発環境を整えるうえで最大の課題はFirestoreのエミュレーションをどうするかですが、Firebase Local Emulator Suiteではうまくやれそうです。

HostingやCloud Functionsも当然のことながらエミュレートするのですが、当方の開発環境は仮想マシン上に構築しているため、ネットワーク越しのアクセスとなります。ところが、

firebase emulators:start --help

としてみても

Usage: firebase emulators:start [options]

start the local Firebase emulators

Options:
  --only <emulators>          only specific emulators. This is a comma separated list of emulator names. Valid
                              options are: ["functions","firestore","database","hosting","pubsub"]
  --inspect-functions [port]  emulate Cloud Functions in debug mode with the node inspector on the given port
                              (9229 if not specified)
  --import [dir]              import emulator data from a previous export (see emulators:export)
  -h, --help                  output usage information

となっておりホストの設定オプションがない。こちらのStack Overflowの記事に助けられました・・・。

その後かろうじてソースコード内にドキュメントらしきものを発見しました。めでたしめでたし(?)

7
3
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
7
3