From 52619fea8dc2a41d2bc5a6b655ff3368f0fd01f7 Mon Sep 17 00:00:00 2001 From: Reet Chowdhary Date: Fri, 29 Mar 2019 02:32:01 -0400 Subject: [PATCH 1/2] websocket uri change for api-layer Signed-off-by: Reet Chowdhary --- bootstrap/src/uri/mvd-uri.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bootstrap/src/uri/mvd-uri.ts b/bootstrap/src/uri/mvd-uri.ts index ae1a347c2..bc63587e5 100644 --- a/bootstrap/src/uri/mvd-uri.ts +++ b/bootstrap/src/uri/mvd-uri.ts @@ -13,7 +13,7 @@ import { PluginManager } from 'zlux-base/plugin-manager/plugin-manager' const uri_prefix = window.location.pathname.split('ZLUX/plugins/')[0]; -// const proxy_mode = (uri_prefix !== '/') ? true : false; // Tells whether we're behind API layer (true) or not (false) +const proxy_mode = (uri_prefix !== '/') ? true : false; // Tells whether we're behind API layer (true) or not (false) export class MvdUri implements ZLUX.UriBroker { rasUri(uri: string): string { @@ -108,8 +108,9 @@ export class MvdUri implements ZLUX.UriBroker { } const protocol = window.location.protocol; const wsProtocol = (protocol === 'https:') ? 'wss:' : 'ws:'; - return `${wsProtocol}//${window.location.host}${this.pluginRootUri(plugin)}` + const uri = `${wsProtocol}//${window.location.host}${this.pluginRootUri(plugin)}` + `services/${serviceName}/${version}/${relativePath}`; + return proxy_mode ? uri.replace('ui', 'ws') : uri; } /** From a482d3df3c4420ab198d3643cc46064768931cbc Mon Sep 17 00:00:00 2001 From: Reet Chowdhary Date: Fri, 29 Mar 2019 13:57:32 -0400 Subject: [PATCH 2/2] minor change to replace and added comment explaining it Signed-off-by: Reet Chowdhary --- bootstrap/src/uri/mvd-uri.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bootstrap/src/uri/mvd-uri.ts b/bootstrap/src/uri/mvd-uri.ts index bc63587e5..1082cb637 100644 --- a/bootstrap/src/uri/mvd-uri.ts +++ b/bootstrap/src/uri/mvd-uri.ts @@ -110,7 +110,9 @@ export class MvdUri implements ZLUX.UriBroker { const wsProtocol = (protocol === 'https:') ? 'wss:' : 'ws:'; const uri = `${wsProtocol}//${window.location.host}${this.pluginRootUri(plugin)}` + `services/${serviceName}/${version}/${relativePath}`; - return proxy_mode ? uri.replace('ui', 'ws') : uri; + // This is a workaround for the mediation layer not having a dynamic way to get the websocket uri for zlux + // Since we know our uri is /ui/v1/zlux/ behind the api-layer we replace the ui with ws to get /ws/v1/zlux/ + return proxy_mode ? uri.replace('/ui/', '/ws/') : uri; } /**