Browser on another laptop is not detected
I tried on two different browsers (localhost:8080) on the same laptop and it works.
But when I open it on another laptop in the same network (of course using its ip), devices are not detected.
There are no logs on nginx nor nodejs app.
How can I configure it to use it on any device on the same network?
Thanks
When you visit your website on LAN, the server can only get your devices' LAN IP. Each device has different LAN IP, so the server can't recognize that they are in same network.
To solve this problem you need modify index.js _setIP(request) function, add a judgment, if ip start with, let's say your LAN is 192.168.1. , just take 192.168.1 as this.ip, ignore the last section of the ip address.
@yjmp14
When you visit your website on LAN, the server can only get your devices' LAN IP. Each device has different LAN IP, so the server can't recognize that they are in same network. To solve this problem you need modify
index.js_setIP(request)function, add a judgment, if ip start with, let's say your LAN is192.168.1., just take192.168.1asthis.ip, ignore the last section of the ip address.
Did you mean this way?
_setIP(request) {
if (request.headers['x-forwarded-for']) {
this.ip = request.headers['x-forwarded-for'].split(/\s*,\s*/)[0];
} else {
this.ip = request.connection.remoteAddress;
}
// IPv4 and IPv6 use different values to refer to localhost
if (this.ip == '::1' || this.ip == '::ffff:127.0.0.1') {
this.ip = '127.0.0.1';
}
if (this.ip.startsWith('192.168.0.') {
this.ip = '192.168.0';
}
}
Does not seem to work for me. Can you help?
just take
192.168.1asthis.ip, ignore the last section of the ip address.
I could not understand this part.
@jrichardsz
https://github.com/RobinLinus/snapdrop/issues/159#issuecomment-691678186 This solved the issue for me!
https://github.com/RobinLinus/snapdrop/issues/159#issuecomment-685751010 The reason for the devices on the same LAN not being detected seems to be this.
Hope it helps.