Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(emulator): Hosting emulator should not connect to 0.0.0.0 for emulators #3141

Merged
merged 3 commits into from
Feb 16, 2021
Merged

Conversation

lisp719
Copy link
Contributor

@lisp719 lisp719 commented Feb 16, 2021

Description

Fix for (#3121): Fixed to connect to 127.0.0.1 when host is set to 0.0.0.0 in firebase.json

Scenarios Tested

public/index.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Welcome to Firebase Hosting</title>

    <script defer src="/__/firebase/8.2.7/firebase-app.js"></script>
    <script defer src="/__/firebase/8.2.7/firebase-firestore.js"></script>
    <script defer src="/__/firebase/init.js?useEmulator=true"></script>
  </head>
  <body>
    <script>
      document.addEventListener("DOMContentLoaded", function () {
        firebase
          .firestore()
          .doc("/foo/bar")
          .get()
          .then((doc) => {
            console.log(doc.exists);
          });
      });
    </script>
  </body>
</html>

firebase.json

{
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "hosting": {
    "public": "public",
    "ignore": ["firebase.json", "**/.*", "**/node_modules/**"]
  },
  "emulators": {
    "firestore": {
      "host": "0.0.0.0",
      "port": 8080
    },
    "hosting": {
      "host": "0.0.0.0",
      "port": 5000
    },
    "ui": {
      "enabled": false
    }
  }
}

Sample Commands

@google-cla
Copy link

google-cla bot commented Feb 16, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@samtstern
Copy link
Contributor

@lisp719 thank you for this PR! Assigning to @yuchenshi for review.

@lisp719
Copy link
Contributor Author

lisp719 commented Feb 16, 2021

@googlebot I signed it!

@google-cla google-cla bot added cla: yes Manual indication that this has passed CLA. and removed cla: no labels Feb 16, 2021
CHANGELOG.md Outdated Show resolved Hide resolved
@yuchenshi
Copy link
Member

Thank you! Merging in this soon.

@yuchenshi yuchenshi merged commit ea06936 into firebase:master Feb 16, 2021
devpeerapong pushed a commit to devpeerapong/firebase-tools that referenced this pull request Dec 14, 2021
…lators (firebase#3141)

* fix(emulator): Hosting emulator should not connect to 0.0.0.0 for emulators (firebase#3121)

* Update CHANGELOG.md

Co-authored-by: Yuchen Shi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Manual indication that this has passed CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants