I'm using bun v0.1.7 (NOT nodejs), I'm trying the built-in basic http server without any other framework:
export default {
port: 3000,
fetch(request: Request) {
const remoteIp = request.headers.get('x-forwarded-for') || 'UNKNOWN';
return new Response(remoteIp);
},
};
Can I get the remote IP from the client when I'm not using any proxies ?
I've tried request.connenction.remoteAddress
, request.socket...
But nothing seems to be implemented.
CodePudding user response:
Currently (v 0.1.7), the Bun.serve Request object doesn't add anything to the Request object beyond the standard. According to Discord question
However, It's possible that in a future the Request object was extended by Bun.serve with additional data like remoteIp, cookies, etc. Just like node http server does.