Skip to content

Commit

Permalink
fix: remoteAddr hardcoded to localhost:1234 (#1839)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinrempel authored Oct 2, 2023
1 parent 4295dbe commit 0a0d86e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/server/boot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/server_components_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Deno.test({
transport: "tcp",
},
remoteAddr: {
hostname: "localhost",
hostname: "127.0.0.1",
port: 8000,
transport: "tcp",
},
Expand Down

0 comments on commit 0a0d86e

Please sign in to comment.