Skip to content

Add support for connecting to server with wss #10

@stennie

Description

@stennie

Neuro currently assumes unencrypted connections, which will prevent connecting from a client served via https to an unencrypted server:

this.websocket = new WebSocket(`ws://${this.hostname}:${this.port}`);

Expected error message in Chrome:

neuro-app.html.js:85 Mixed Content: The page at 'https://...' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws://...'. This request has been blocked; this endpoint must be available over WSS.

There's probably a more elegant way to fix this, but my quick fix for connecting to a Heroku dyno is to switch to wss based on the port:

-        this.websocket = new WebSocket(`ws://${this.hostname}:${this.port}`);
+        let protocol = (this.port == 443 ? 'wss' : 'ws');
+        this.websocket = new WebSocket(`${protocol}://${this.hostname}:${this.port}`);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions