diff --git a/server/channels/api4/websocket.go b/server/channels/api4/websocket.go index 3f4ccc7e294..53fc767a674 100644 --- a/server/channels/api4/websocket.go +++ b/server/channels/api4/websocket.go @@ -32,7 +32,10 @@ func connectWebSocket(c *Context, w http.ResponseWriter, r *http.Request) { ws, err := upgrader.Upgrade(w, r, nil) if err != nil { - c.Err = model.NewAppError("connect", "api.web_socket.connect.upgrade.app_error", nil, err.Error(), http.StatusBadRequest) + params := map[string]any{ + "BlockedOrigin": r.Header.Get("Origin"), + } + c.Err = model.NewAppError("connect", "api.web_socket.connect.upgrade.app_error", params, err.Error(), http.StatusBadRequest) return } diff --git a/server/channels/api4/websocket_test.go b/server/channels/api4/websocket_test.go index ecd9bb38cdf..200fba41c45 100644 --- a/server/channels/api4/websocket_test.go +++ b/server/channels/api4/websocket_test.go @@ -465,5 +465,5 @@ func TestWebSocketUpgrade(t *testing.T) { require.NoError(t, err) require.Equal(t, resp.StatusCode, http.StatusBadRequest) require.NoError(t, th.TestLogger.Flush()) - testlib.AssertLog(t, buffer, mlog.LvlDebug.Name, "Failed to upgrade websocket connection.") + testlib.AssertLog(t, buffer, mlog.LvlDebug.Name, "URL Blocked because of CORS. Url: ") } diff --git a/server/i18n/en.json b/server/i18n/en.json index 6178727e301..d5e51cd584c 100644 --- a/server/i18n/en.json +++ b/server/i18n/en.json @@ -4552,7 +4552,7 @@ }, { "id": "api.web_socket.connect.upgrade.app_error", - "translation": "Failed to upgrade websocket connection." + "translation": "URL Blocked because of CORS. Url: {{.BlockedOrigin}}" }, { "id": "api.web_socket_router.bad_action.app_error",