request-ip icon indicating copy to clipboard operation
request-ip copied to clipboard

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

Open marlon-chagas opened this issue 1 year ago • 3 comments

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?

marlon-chagas avatar May 02 '23 21:05 marlon-chagas

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

Ismaaa avatar Jun 13 '23 19:06 Ismaaa

@pbojinov

System233 avatar Oct 08 '23 09:10 System233

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.

System233 avatar Oct 09 '23 04:10 System233