Skip to content

Commit

Permalink
Bug Fix on unsecured websockets (#64)
Browse files Browse the repository at this point in the history
* Bug Fix on unsecured websockets

* Fix WS

Use host instead of hostname to keep port information
  • Loading branch information
ggerbaud authored and mathieu-pousse committed Sep 12, 2016
1 parent 398dea5 commit e7523aa
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions webapp/src/ViewGame.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ class ViewGame extends Component {
.catch((error) => console.log(error))

var wsProtocol = "wss";
if (window.location.protocol == "http") {
if (window.location.protocol == "http:") {
// keep using non secured connection
wsProtocol = "ws";
}
this.ws = new WebSocket(wsProtocol + '://' + window.location.hostname + '/api/games/' + this.state.gameId + '/ws');
this.ws = new WebSocket(wsProtocol + '://' + window.location.host + '/api/games/' + this.state.gameId + '/ws');
this.ws.onmessage = (event) => this.updateGameState(JSON.parse(event.data))
}

Expand Down

0 comments on commit e7523aa

Please sign in to comment.