Allow connections from all origins.

This commit is contained in:
Marco 2022-12-18 01:41:44 +01:00
parent 7da9b2dcb2
commit 516a5fa547
2 changed files with 4 additions and 1 deletions

View File

@ -106,7 +106,7 @@ func (game *chessGame) handle() {
}
func addPlayersToGame(players [2]Player) {
log.Printf("Adding players \n%d\n%d\nto new game", players[0].id, players[1].id)
log.Printf("Adding players %d and %d to new game", players[0].id, players[1].id)
game := NewChessGame(rand.Int(), players)
go game.handle()

View File

@ -14,6 +14,9 @@ var upgrader = websocket.Upgrader{} // use default options
func SocketHandler(w http.ResponseWriter, r *http.Request) {
log.Println("SocketHandler invoked")
// Allow connections from any origin
upgrader.CheckOrigin = func(r *http.Request) bool { return true }
conn, err := upgrader.Upgrade(w, r, nil)
if err != nil {
log.Print("Error during connection upgrading:", err)