mirror of
https://github.com/OpenEPaperLink/OpenEPaperLink.git
synced 2026-03-21 09:04:24 +01:00
Make WebSocket connection protocol dependent (#191)
Currently, the connection to WebSockets is hardcoded to the protocol "ws://". If the server is put behind a proxy server (like Nginx) to support "https", the connection to websockets will fail (at least in Firefox) due to insecure protocol. This change checks the current protocol and connects to "wss" if loaded via "https", which makes it work when loaded via proxy.
This commit is contained in:
Binary file not shown.
@@ -113,7 +113,8 @@ function loadTags(pos) {
|
||||
}
|
||||
|
||||
function connect() {
|
||||
socket = new WebSocket("ws://" + location.host + "/ws");
|
||||
protocol = location.protocol == "https:" ? "wss://" : "ws://";
|
||||
socket = new WebSocket(protocol + location.host + "/ws");
|
||||
|
||||
socket.addEventListener("open", (event) => {
|
||||
showMessage("websocket connected");
|
||||
|
||||
Reference in New Issue
Block a user