mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-14 20:03:52 +00:00
fix: secure protocol resolution
This commit is contained in:
committed by
Carlos Valente
parent
8bc3f5a56c
commit
bfb9b51073
@@ -34,9 +34,12 @@ export const websocketUrl = resolveUrl('ws', 'ws');
|
|||||||
function resolveUrl(protocol: 'http' | 'ws', path: string) {
|
function resolveUrl(protocol: 'http' | 'ws', path: string) {
|
||||||
const url = new URL(window.location.origin);
|
const url = new URL(window.location.origin);
|
||||||
|
|
||||||
// check if protocol URL is secure
|
// generate ws url
|
||||||
url.protocol = protocol === 'http' ? 'http' : 'ws';
|
if (protocol === 'ws') {
|
||||||
url.protocol += window.location.protocol === 'https:' ? 's' : '';
|
// ensure we remain in a secure context
|
||||||
|
const isSecure = window.location.protocol === 'https:';
|
||||||
|
url.protocol = isSecure ? 'wss' : 'ws';
|
||||||
|
}
|
||||||
|
|
||||||
// make path name relative to the base URI
|
// make path name relative to the base URI
|
||||||
url.pathname = baseURI ? `${baseURI}/${path}` : path;
|
url.pathname = baseURI ? `${baseURI}/${path}` : path;
|
||||||
|
|||||||
Reference in New Issue
Block a user