Skip to content

Node settings page: WebSocket connection string uses internal bind port instead of location.host #380

@lijunle-bot

Description

@lijunle-bot

Bug

gatewayWsUrl() in page-nodes.js (L26-30) constructs the WebSocket connection string using gon.get("port") — the server's internal bind port from config. When behind a reverse proxy or tunnel, this produces a wrong URL like wss://example.com:38309/ws instead of wss://example.com/ws.

function gatewayWsUrl() {
    var proto = location.protocol === "https:" ? "wss:" : "ws:";
    var port = gon.get("port") || location.port;  // ← uses server bind port
    var host = location.hostname;
    return `${proto}//${host}${port ? `:${port}` : ""}/ws`;
}

Every other WebSocket connection in the codebase correctly uses location.host:

File Line URL Construction
ws-connect.js L44 `${proto}//${location.host}/ws/chat`
page-settings.js L1874 `${wsProtocol}//${window.location.host}/graphql`
page-terminal.js L805 `${proto}//${location.host}/api/terminal/ws`

Fix

Align with the rest of the codebase:

function gatewayWsUrl() {
    var proto = location.protocol === "https:" ? "wss:" : "ws:";
    return `${proto}//${location.host}/ws`;
}

location.host already includes the correct hostname and port (or omits it when it's the default 443/80).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions