var app = require("express")();
var server = require("http").Server(app);
var io = require("socket.io")(server);
var requestIp = require('request-ip');
server.listen(3000);
var ipMiddleware = function(req, res) {
return requestIp.getClientIp(req);
};
var ip = null;
app.get("/", function (req, res) {
ip = ipMiddleware(req, res);
res.sendFile(__dirname + "/index.html");
});
io.on("connection", function (socket) {
});
My problem is that I would like to get the ip address of the client with the expression and fix the ip address for the client, ips are different, then this should be, how can I emit the ip that I get with the expression? thank
source
share