Add origin to the websocket connection (#208)

* Add origin to the websocket connection

* parse the url with a regex
This commit is contained in:
enahum 2017-02-01 11:28:37 -03:00 committed by Harrison Healey
parent 9ca8d5d3ac
commit 45ad4268eb

View file

@ -51,7 +51,10 @@ class WebSocketClient {
if (this.connectingCallback) {
this.connectingCallback(dispatch, getState);
}
this.conn = new Socket(connectionUrl);
const captured = (/^(?:https?|wss?):\/\/[^/]*/).exec(connectionUrl);
const origin = captured ? captured[0] : null;
this.conn = new Socket(connectionUrl, null, {origin});
this.connectionUrl = connectionUrl;
this.token = token;
this.dispatch = dispatch;