mirror of
https://github.com/denoland/deno.git
synced 2025-01-11 08:33:43 -05:00
fix(ext/http): Include hostname in onListen argument (#19497)
Closes #19470.
This commit is contained in:
parent
ec8e9d4f5b
commit
4b67ffe11b
1 changed files with 8 additions and 7 deletions
|
@ -635,16 +635,17 @@ function serve(arg1, arg2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const onListen = (scheme) => {
|
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;
|
const port = listenOpts.port;
|
||||||
|
|
||||||
if (options.onListen) {
|
if (options.onListen) {
|
||||||
options.onListen({ port });
|
options.onListen({ hostname, port });
|
||||||
} else {
|
} 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}/`);
|
console.log(`Listening on ${scheme}${hostname}:${port}/`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue