If you are not the one running the server or don't know the stack used, it will be hard to figure out.
One example of server software with websocket is gotty
(it uses implementation github.com/gorilla/websocket).
For gotty server to allow any origin
value, command & params to start it must be:
> gotty -w --ws-origin ".*" bash
--ws-origin value A regular expression that matches
origin URLs to be accepted by WebSocket. No cross origin requests are
acceptable by default [$GOTTY_WS_ORIGIN]
On a chrome console, you can now execute below without errors:
url = 'ws://<host>:<port>/ws';
const w = new WebSocket(url)
It seems the protocol do mention it:
The |Origin| header field [RFC6454] is used to protect against
unauthorized cross-origin use of a WebSocket server by scripts using
the WebSocket API in a web browser.