firebase cli serve cant access the project from different device

后端 未结 4 2002
醉酒成梦
醉酒成梦 2021-01-11 13:55

I have install firebase cli etcetc. I can start the project and develop using firebase serve. I can visit the page of the project through localhost:5000 but if i try from di

4条回答
  •  我在风中等你
    2021-01-11 14:42

    This worked for me. I found the config.json file for the functions-emulator (It's in user/.config/configstore/@googlecloud/functions-emulator/config.json on mac or windows) and changed "bindHost": "localhost", to "bindHost": "0.0.0.0" and then I could access served functions from other devices on my network via localip:5000 which wasn't working before.

    Tivoli commented on Aug 20, 2017 •

    Digging around the code I figured this out, it's because the firebase-tools is only setting the projectId as part of the functions-emulator config. This fixes it in my Dockerfile

    ADD config.json /root/.config/configstore/@google-cloud/functions-emulator/config.json

    and the config.json looks like this

    {
    "bindHost": "0.0.0.0" }

    You can change the 0.0.0.0 to any host you want, but this works for Docker.

    For reference https://github.com/firebase/firebase-tools/blob/master/lib/serve/functions.js#L71 is the offending block, it needs to set the above parameter to the same as the --host command line parameter.

    If you are running on your own local machine then you need to set it to the configstore folder for your respective OS on OS X it would be ~/.config/configstore/@google-cloud/functions-emulator/config.json.

    Reference for the default config values https://github.com/GoogleCloudPlatform/cloud-functions-emulator/blob/master/src/defaults.json

提交回复
热议问题