Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for connecting to server with wss #10

Open
stennie opened this issue Oct 25, 2020 · 0 comments
Open

Add support for connecting to server with wss #10

stennie opened this issue Oct 25, 2020 · 0 comments

Comments

@stennie
Copy link
Contributor

stennie commented Oct 25, 2020

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}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant