Skip to content

Commit

Permalink
Handle WebSockets over HTTPS
Browse files Browse the repository at this point in the history
  • Loading branch information
motet-a committed Nov 13, 2017
1 parent 0bac071 commit 264290f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion client/src/ws.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const connect = () => {
throw new Error('WebSocket not closed')
}

ws = new WebSocket('ws://' + location.host + '/ws')
const protocol = window.location.protocol == 'https:' ? 'wss:' : 'ws:'
ws = new WebSocket(protocol + '//' + window.location.host + '/ws')

ws.onopen = event => {
ws.onmessage = event => {
Expand Down

0 comments on commit 264290f

Please sign in to comment.