From fb6bf720b9a5925654a1eef48f442e621051e7c8 Mon Sep 17 00:00:00 2001 From: Oleg Romanchuk Date: Wed, 21 Aug 2024 14:01:03 -0400 Subject: [PATCH] Fix error message reference and allow all origins in WebSocket upgrader - Updated the WebSocket upgrader to allow all origins by setting CheckOrigin to always return true. - Corrected the error message reference from 'er.Message' to 'er.ErrMsg' in the Error callback function. --- main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index ff899e4..a587be5 100644 --- a/main.go +++ b/main.go @@ -20,6 +20,10 @@ import ( var upgrader = websocket.Upgrader{ ReadBufferSize: 1024, WriteBufferSize: 1024, + // Allow all origins + CheckOrigin: func(r *http.Request) bool { + return true + }, } type WebSocketMessage struct { @@ -76,7 +80,7 @@ func (c MyCallback) UtteranceEnd(ur *api.UtteranceEndResponse) error { func (c MyCallback) Error(er *api.ErrorResponse) error { fmt.Printf("\n[Error] Received\n") fmt.Printf("Error.Type: %s\n", er.Type) - fmt.Printf("Error.Message: %s\n", er.Message) + fmt.Printf("Error.Message: %s\n", er.ErrMsg) fmt.Printf("Error.Description: %s\n\n", er.Description) return nil }