sockjs / sockjs-client

WebSocket emulation - Javascript client
MIT License
8.45k stars 1.3k forks source link

Connecting from an HTTPS website to a 'localhost' url doesn't work #645

Open TalaatHarb opened 10 months ago

TalaatHarb commented 10 months ago

I was trying to make a connection to a server running at http://localhost:3008 serving sock-js communication but it failed to connect, switching to http://127.0.0.1:3008 made it work. I believe it is due to: 'urlUtils.isLoopbackAddr(parsedUrl.host)' not accepting 'localhost' as a loopback address so it fails to connect from any HTTPS website.

before this commit, https://github.com/sockjs/sockjs-client/commit/a57c910001e937d784c7bfcdcb05cfbbbc625934 it failed also for 127.0.0.1 but now '// exception is 127.0.0.0/8 and ::1 urls' which doesn't include localhost.