0

I have an issue. I want to store the ipv4 of a user in my database. For that I am using this external API called https://ipapi.co/json.

I am trying to implement the system. I have thought of a solution and it goes this way - On the website, as soon as a user visits a page, an ajax get request is made to that API which fetches the user's ip and stores it in an input type= hidden to which I can get access in req.body and store in the database.

In order to avoid the user use chromedevtools to change that attribute I can add oncontextmenu="return false" onkeydown="return false;" onmousedown="return false;" to the body so that user cannot get access to the chrome devtools.

I am not sure if this will work out. Can you guys please suggest.

Another doubt that I have is that is the ajax request is made by the user or by the server? If the server makes the request then IP will be of the server which is useless. Please help!

Codenewbie
  • 1,106
  • 7
  • 21
  • 1
    You can't stop a user from submitting false/fake information. Getting the request [network ip](https://stackoverflow.com/questions/10849687/express-js-how-to-get-remote-client-address) – Matt Sep 03 '20 at 05:39

1 Answers1

1

once a user gets into your site a get request method is been done . And in the request object you can get the ip

Ernesto
  • 1,911
  • 1
  • 9
  • 18