fix: Use relative paths for noVNC

This commit is contained in:
Haozhe Xie
2024-11-15 11:12:16 +08:00
committed by GitHub
parent 771cecdefb
commit a37db1b054
4 changed files with 12 additions and 6 deletions

View File

@@ -21,7 +21,7 @@ var webSocketFactory = {
function getInfo() {
var url = "/msg.html";
var url = "msg.html";
try {
if (window.XMLHttpRequest) {
@@ -69,7 +69,12 @@ function processInfo() {
if (notFound) {
setInfo("Connecting to VNC", true);
var webSocket = webSocketFactory.connect("ws://" + window.location.host + "/websockify");
var protocol = window.location.protocol === "https:" ? "wss:" : "ws:";
var path = window.location.pathname.replace(/[^/]*$/, '').replace(/\/$/, '');
var wsUrl = protocol + "//" + window.location.host + path + "/websockify";
var webSocket = webSocketFactory.connect(wsUrl);
return true;
}