Get IP Address in tRPC router
Hey guys how can I get the IP address inside a procedure?
Like this code f.ex:
8 Replies
not 100% but think you can do and then on the request object you may be able to grab or and pass that to your context?
@sommeeer
im not using any user tho
its a public procedure
i meant and pass the ip to ctx
not 100% sure on this, but might be possible this way.
ok
@sommeeer did that help or nah?
Didnt figure it out :/
dang keep at it im sure you can brute force the solution eventually. Thats how i do things
this worked for me
const clientIP = req.headers['x-forwarded-for'] || req.socket.remoteAddress;
I did that in express, I haven't tried it in trpc