diff --git a/index.js b/index.js index 77a2a7e..5231bff 100644 --- a/index.js +++ b/index.js @@ -315,6 +315,10 @@ LiveServer.start = function(options) { // WebSocket var clients = []; server.addListener('upgrade', function(request, socket, head) { + + // Ignore requests that are not from `/live-server-socket` URLs + if (!/\/live-server-socket$/.test(request.url)) return; + var ws = new WebSocket(request, socket, head); ws.onopen = function() { ws.send('connected'); }; diff --git a/injected.html b/injected.html index 59b7695..e822bc8 100644 --- a/injected.html +++ b/injected.html @@ -18,7 +18,7 @@ } } var protocol = window.location.protocol === 'http:' ? 'ws://' : 'wss://'; - var address = protocol + window.location.host + window.location.pathname + '/ws'; + var address = protocol + window.location.host + window.location.pathname + '/live-server-socket'; var socket = new WebSocket(address); socket.onmessage = function(msg) { if (msg.data == 'reload') window.location.reload();