In my Deno applicaiton, I'm able to access the client's IP address on each request using some fairly convoluted, but nonetheless functional, means:
const app = new Hono();
app.get("/", (ctx) => {
return ctx.body(ctx.env.remoteAddr());
});
serve(async (request, connInfo) => {
const remoteAddr = () => resolveRemoteAddr(connInfo.remoteAddr);
const env = { remoteAddr };
return app.fetch(request, env);
}, {
hostname: "0.0.0.0",
port: 3001,
});
This does not appear possible in an equivalent node application, using honojs/node-server. The function returned by getRequestListener has access to the IncomingMessage structure, which makes this available via message.socket.remoteAddress, but that is not itself made available to the fetchCallback, and the undici Request object that is passed to the route doesn't appear to provide access to it either.
Am I missing something?
In my Deno applicaiton, I'm able to access the client's IP address on each request using some fairly convoluted, but nonetheless functional, means:
This does not appear possible in an equivalent node application, using
honojs/node-server. The function returned bygetRequestListenerhas access to theIncomingMessagestructure, which makes this available viamessage.socket.remoteAddress, but that is not itself made available to thefetchCallback, and the undiciRequestobject that is passed to the route doesn't appear to provide access to it either.Am I missing something?