Skip to content

Commit 47c78b7

Browse files
lisp719yuchenshi
authored andcommitted
fix(emulator): Hosting emulator should not connect to 0.0.0.0 for emulators (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]>
1 parent 807b90e commit 47c78b7

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
- Fixes issue where proxied requests to dynamic content through the Hosting emulator would return unexpected `location` headers. (#3097)
22
- Fixes issue where optional extension parameters could not be omitted. (#3126)
33
- Fixes issue where deploying Cloud Functions for Firebase fails on Node.js v15. (#3120)
4+
- Fixes issue where hosting emulator would connect to 0.0.0.0 for emulators. (#3121)

src/hosting/implicitInit.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,17 @@ export async function implicitInit(options: any): Promise<TemplateServerResponse
6868
const info = EmulatorRegistry.getInfo(e);
6969

7070
if (info) {
71-
// IPv6 hosts need to be quoted using brackets.
72-
const host = info.host.includes(":") ? `[${info.host}]` : info.host;
71+
let host = info.host;
72+
73+
if (host === "0.0.0.0") {
74+
host = "127.0.0.1";
75+
} else if (host === "::") {
76+
host = "[::1]";
77+
} else if (host.includes(":")) {
78+
// IPv6 hosts need to be quoted using brackets.
79+
host = `[${host}]`;
80+
}
81+
7382
emulators[e] = {
7483
host,
7584
port: info.port,

0 commit comments

Comments
 (0)