summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/http/00_serve.js15
1 files changed, 8 insertions, 7 deletions
diff --git a/ext/http/00_serve.js b/ext/http/00_serve.js
index be9c9d801..761c3219e 100644
--- a/ext/http/00_serve.js
+++ b/ext/http/00_serve.js
@@ -635,16 +635,17 @@ function serve(arg1, arg2) {
}
const onListen = (scheme) => {
+ // If the hostname is "0.0.0.0", we display "localhost" in console
+ // because browsers in Windows don't resolve "0.0.0.0".
+ // See the discussion in https://github.com/denoland/deno_std/issues/1165
+ const hostname = listenOpts.hostname == "0.0.0.0"
+ ? "localhost"
+ : listenOpts.hostname;
const port = listenOpts.port;
+
if (options.onListen) {
- options.onListen({ port });
+ options.onListen({ hostname, port });
} else {
- // If the hostname is "0.0.0.0", we display "localhost" in console
- // because browsers in Windows don't resolve "0.0.0.0".
- // See the discussion in https://github.com/denoland/deno_std/issues/1165
- const hostname = listenOpts.hostname == "0.0.0.0"
- ? "localhost"
- : listenOpts.hostname;
console.log(`Listening on ${scheme}${hostname}:${port}/`);
}
};