fix: remoteAddr hardcoded to localhost:1234 (#1839)

This commit is contained in:
Martin Rempel
2023-10-02 16:30:13 +00:00
committed by GitHub
parent 4295dbe85d
commit 0a0d86e3a5
2 changed files with 13 additions and 2 deletions
+12 -1
View File
@@ -60,7 +60,18 @@ async function bootServer(handler: ServeHandler, opts: StartOptions) {
// @ts-ignore Ignore type error when type checking with Deno versions
if (typeof Deno.serve === "function") {
// @ts-ignore Ignore type error when type checking with Deno versions
await Deno.serve(opts, handler).finished;
await Deno.serve(
opts,
(r, { remoteAddr }) =>
handler(r, {
remoteAddr,
localAddr: {
transport: "tcp",
hostname: opts.hostname ?? "localhost",
port: opts.port,
} as Deno.NetAddr,
}),
).finished;
} else {
// @ts-ignore Deprecated std serve way
await serve(handler, opts);
+1 -1
View File
@@ -82,7 +82,7 @@ Deno.test({
transport: "tcp",
},
remoteAddr: {
hostname: "localhost",
hostname: "127.0.0.1",
port: 8000,
transport: "tcp",
},