fix: remoteAddr hardcoded to localhost:1234 (#1839)
This commit is contained in:
+12
-1
@@ -60,7 +60,18 @@ async function bootServer(handler: ServeHandler, opts: StartOptions) {
|
|||||||
// @ts-ignore Ignore type error when type checking with Deno versions
|
// @ts-ignore Ignore type error when type checking with Deno versions
|
||||||
if (typeof Deno.serve === "function") {
|
if (typeof Deno.serve === "function") {
|
||||||
// @ts-ignore Ignore type error when type checking with Deno versions
|
// @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 {
|
} else {
|
||||||
// @ts-ignore Deprecated std serve way
|
// @ts-ignore Deprecated std serve way
|
||||||
await serve(handler, opts);
|
await serve(handler, opts);
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ Deno.test({
|
|||||||
transport: "tcp",
|
transport: "tcp",
|
||||||
},
|
},
|
||||||
remoteAddr: {
|
remoteAddr: {
|
||||||
hostname: "localhost",
|
hostname: "127.0.0.1",
|
||||||
port: 8000,
|
port: 8000,
|
||||||
transport: "tcp",
|
transport: "tcp",
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user