Skip to content

Better dynamic WebSocket URL (for reverse proxy) #7

@ServeurpersoCom

Description

@ServeurpersoCom

I use reverse proxy to put the stream inside the main HTTP/HTTPS port of my webserver, here is my working code at beginning of client.js :

I think you can remove my "CUSTOM" const and put this trick inside your code for better compatibility.

const CUSTOM = "ReverseProxy";

var port = window.location.port;
if (window.location.protocol == 'https:') {
        var protocol = 'wss:'
        if (!port) port = '443'
} else {
        var protocol = 'ws:'
        if (!port) port = '80'
}
 
startStream('video', 'videostats', protocol+'//'+window.location.hostname+':'+port+'/'+CUSTOM, true, 'auto', 2000)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions