pbojinov / request-ip

A Node.js module for retrieving a request's IP address on the server.
https://npmjs.com/package/request-ip
MIT License
830 stars 102 forks source link

(node:71664) [FSTDEP005] FastifyDeprecation "request.connection" #86

Open marlon-chagas opened 1 year ago

marlon-chagas commented 1 year ago

Im using request-ip in my fastify application and after I updated to Fastify@4 Im getting following warning:

(node:71664) [FSTDEP005] FastifyDeprecation: You are accessing the deprecated "request.connection" property. 
Use "request.socket" instead.
    at Object.emit (xxxx/process-warning/index.js:52:13)
    at Request.get (xxxx/fastify/lib/request.js:211:17)
    at Object.getClientIp (xxxx/request-ip/lib/index.js:88:21)
    at resolveIp (xxxx/dist/middlewares/my-file.js:7:89)
    at Object.fastifyReqLogger [as req] (xxxxx/dist/main.js:62:69)
    at Pino.asJson (xxxx/pino/lib/tools.js:132:33)
    at Pino.write (xxxx/pino/lib/proto.js:205:28)
    at Pino.LOG [as info] (xxxx/pino/lib/tools.js:62:21)
    at Object.routeHandler [as handler] (xxxx/fastify/lib/route.js:470:19)
    at Router.callHandler (xxxx/find-my-way/index.js:398:14)"

It is a simple fix by modifying the following code snippet: image

as the latest version of fastify suggests.

Can I open PR with that fix?

Ismaaa commented 1 year ago

Your contribution sounds valuable @marlon-chagas ! Please do open a PR with your fix.

System233 commented 1 year ago

@pbojinov

System233 commented 1 year ago

Repository not maintained. For fastify OR express you probably don't need request-ip, they have built-in support, check out fastify-trustproxy or expess-behind-proxies.