Coding
In the index.js Start by importing express and initializing the app and sending all the get requests to the host with IP address of the client.
const app = require('express')().get("/*", (req, res) => {res.send({IP:req.headers["x-forwarded-for"]?.split(",").shift() ||req.socket?.remoteAddress });});
app.listen(3000, () => console.log("Listening on port 3000"));
Now run the code with
node api/index.js
and open localhost:3000 on the browser.


Since the app is locally hosted you get the localhost host IP address that is
::1
3
