I'm having trouble opening a website in Chrome. There seems to be some CORS policy in chrome for websockets.
If I am on www.example.com and try to open websocket on api.example.com, it will say pending on the console tab of the console and throw onerror with a message WebSocket connection to 'wss://api.example.com' failed: Connection closed before receiving a handshake response. If I look at the server, I do not see a request to connect to the web socket, so there is no response to the request for parameters or the ability to set the Access-Control-Allow-Origin header. However, if I first make a request to api.example.com, which redirects me to www.example.com in the browser, it will work fine.
Do you need to use the same origin for websocket requests in chrome?
Note. This problem is only related to chrome.
source
share