summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/http.ts
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2024-04-05 17:42:26 +0530
committerGitHub <noreply@github.com>2024-04-05 17:42:26 +0530
commitee4bfe16009c3a04c9015bf9fca0c9b0f9a3a601 (patch)
treed02cefbebdfc5f876b6f1549ac94d19fb799fb56 /ext/node/polyfills/http.ts
parentf4b11db072c82f1c5e3af6e601faf3626728ab50 (diff)
fix(ext/node): hostname is valid IPv4 addr (#23243)
Fixes `docusaurus serve`
Diffstat (limited to 'ext/node/polyfills/http.ts')
-rw-r--r--ext/node/polyfills/http.ts5
1 files changed, 4 insertions, 1 deletions
diff --git a/ext/node/polyfills/http.ts b/ext/node/polyfills/http.ts
index 933a8dbcd..67981e8de 100644
--- a/ext/node/polyfills/http.ts
+++ b/ext/node/polyfills/http.ts
@@ -1653,7 +1653,10 @@ export class ServerImpl extends EventEmitter {
// TODO(bnoordhuis) Node prefers [::] when host is omitted,
// we on the other hand default to 0.0.0.0.
- const hostname = options.host ?? "0.0.0.0";
+ let hostname = options.host ?? "0.0.0.0";
+ if (hostname == "localhost") {
+ hostname = "127.0.0.1";
+ }
this.#addr = {
hostname,
port,