mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Connect comms to apiRootUrl
This commit is contained in:
parent
8957d33e49
commit
df8a8ea204
@ -28,6 +28,15 @@ RED.comms = (function() {
|
|||||||
|
|
||||||
function connectWS() {
|
function connectWS() {
|
||||||
active = true;
|
active = true;
|
||||||
|
var wspath;
|
||||||
|
|
||||||
|
if (RED.settings.apiRootUrl) {
|
||||||
|
var m = /^(https?):\/\/(.*)$/.exec(RED.settings.apiRootUrl);
|
||||||
|
if (m) {
|
||||||
|
console.log(m);
|
||||||
|
wspath = "ws"+(m[1]==="https"?"s":"")+"://"+m[2]+"comms";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
var path = location.hostname;
|
var path = location.hostname;
|
||||||
var port = location.port;
|
var port = location.port;
|
||||||
if (port.length !== 0) {
|
if (port.length !== 0) {
|
||||||
@ -35,7 +44,8 @@ RED.comms = (function() {
|
|||||||
}
|
}
|
||||||
path = path+document.location.pathname;
|
path = path+document.location.pathname;
|
||||||
path = path+(path.slice(-1) == "/"?"":"/")+"comms";
|
path = path+(path.slice(-1) == "/"?"":"/")+"comms";
|
||||||
path = "ws"+(document.location.protocol=="https:"?"s":"")+"://"+path;
|
wspath = "ws"+(document.location.protocol=="https:"?"s":"")+"://"+path;
|
||||||
|
}
|
||||||
|
|
||||||
var auth_tokens = RED.settings.get("auth-tokens");
|
var auth_tokens = RED.settings.get("auth-tokens");
|
||||||
pendingAuth = (auth_tokens!=null);
|
pendingAuth = (auth_tokens!=null);
|
||||||
@ -48,7 +58,7 @@ RED.comms = (function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ws = new WebSocket(path);
|
ws = new WebSocket(wspath);
|
||||||
ws.onopen = function() {
|
ws.onopen = function() {
|
||||||
reconnectAttempts = 0;
|
reconnectAttempts = 0;
|
||||||
if (errornotification) {
|
if (errornotification) {
|
||||||
|
Loading…
Reference in New Issue
Block a user