How to get user´s *real* IP-Address in Next13?
Unanswered
Daggertooth pike conger posted this in #help-forum
Daggertooth pike congerOP
I have a typical Express, React (Next13), Node, MongoDB application and need to get access to the user´s ip address on one route because he seems to be malicious.
Problem is, I couldn´t figure out how that works in Next13. The older versions seemed to have a more simple way, but all I get by using thrid party libraries like request-ip is the frontend-server´s IP-address, but not the user´s address.
I assume I somehow need to set the clients IP address in the frontend, or not?
Any help appreciated!
Problem is, I couldn´t figure out how that works in Next13. The older versions seemed to have a more simple way, but all I get by using thrid party libraries like request-ip is the frontend-server´s IP-address, but not the user´s address.
I assume I somehow need to set the clients IP address in the frontend, or not?
Any help appreciated!
5 Replies
ip address is coming from layer 3 IP layer, so you cannot manipulate it. Usually, platform such as Cloudflare, Vercel and other proxies set and forward the IP via layer 7 HTTP header to servers.
Real IP addresses would be hidden by proxies, vpn, Zscaler and so on.
@tafutada777 ip address is coming from layer 3 IP layer, so you cannot manipulate it. Usually, platform such as Cloudflare, Vercel and other proxies set and forward the IP via layer 7 HTTP header to servers.
Australian Freshwater Crocodile
I seem to get the IP of the Cloudflare DNS servers not the actual IP of the user.
I have a pricing section in my website and it shows the currency in Euros and when I checked the IP, it belongs to Clouddflare.
The headers aren't really the IP of the user but rather the DNS/CDN
I have a pricing section in my website and it shows the currency in Euros and when I checked the IP, it belongs to Clouddflare.
The headers aren't really the IP of the user but rather the DNS/CDN
You have any idea how I can tackle this problem?
Torymid wasp
https://developers.cloudflare.com/fundamentals/reference/http-request-headers/#cf-connecting-ip this may be what you are lookin for. Cloudflare also adds a country code header