At present I am using WEBRTC
for getting IP address from client side.
But I have issues with browsers like Internet Explorer etc. I don't want to hit other third party servers for getting IP.
Is there a way to get IP address from ReactJS without hitting third party servers.
Thus, to connect a React frontend with a NodeJS backend, we need to utilize the useEffect hook and the async function fetch() . useEffect will allow us to only run our fetch request once (when the component gets mounted) which will avoid slowing down our app.
listen(PORT, console. log(`Server started on port ${PORT}`)); Frontend setup: First, we have to create React app and run your app by writing the below command. Output: Now go to http://localhost:3000/ in your browser, you will see the following output.
For hosting a react application, NodeJS is the best platform. Node JS can be used for server-side development and React JS for front-end development reducing the need for multiple languages and frameworks.
You can make a request to your own nodejs server and reply with the IP address. that way 3rd party servers wont be involved.
Check sample express code below and use
app.get('/getIP', getClientIP);
Sample code
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With