Prefix websocket path with server path
If noVNC is not served at the root path, prefix the websocket path with the server path. This makes the path to the websocket consistent with the path to all the other web assets. This is convenient so that users do not need to manually change the path setting, though they still can override it. For example if the websockify server is at /some/sub/dir, with this patch noVNC will connect to /some/sub/dir/websockify rather than /websockify.
This commit is contained in:
parent
24231f1ae3
commit
4b59e4523b
16
app/ui.js
16
app/ui.js
|
|
@ -156,6 +156,20 @@ var UI = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var path = 'websockify';
|
||||||
|
// If noVNC is not being served at the root path, prefix
|
||||||
|
// the default websocket path with the server path.
|
||||||
|
var pathName = window.location.pathname.slice(1);
|
||||||
|
if (pathName.length != 0) { // We are not at the root path
|
||||||
|
if (pathName.slice(-1) == '/') {
|
||||||
|
// There's a trailing slash.
|
||||||
|
path = pathName + 'websockify';
|
||||||
|
} else {
|
||||||
|
// There's no trailing slash.
|
||||||
|
path = pathName + '/websockify';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Populate the controls if defaults are provided in the URL */
|
/* Populate the controls if defaults are provided in the URL */
|
||||||
UI.initSetting('host', window.location.hostname);
|
UI.initSetting('host', window.location.hostname);
|
||||||
UI.initSetting('port', port);
|
UI.initSetting('port', port);
|
||||||
|
|
@ -164,7 +178,7 @@ var UI = {
|
||||||
UI.initSetting('resize', 'off');
|
UI.initSetting('resize', 'off');
|
||||||
UI.initSetting('shared', true);
|
UI.initSetting('shared', true);
|
||||||
UI.initSetting('view_only', false);
|
UI.initSetting('view_only', false);
|
||||||
UI.initSetting('path', 'websockify');
|
UI.initSetting('path', path);
|
||||||
UI.initSetting('repeaterID', '');
|
UI.initSetting('repeaterID', '');
|
||||||
UI.initSetting('reconnect', false);
|
UI.initSetting('reconnect', false);
|
||||||
UI.initSetting('reconnect_delay', 5000);
|
UI.initSetting('reconnect_delay', 5000);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue