updated the base url handler to extract any app prefix from the absUrl in case o…
…nos is behind an app prefix Change-Id: I271da533f39091efdd01d8104c1e6740effead52
Showing
1 changed file
with
12 additions
and
1 deletions
| ... | @@ -34,8 +34,19 @@ | ... | @@ -34,8 +34,19 @@ |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | function urlBase(protocol, port, host) { | 36 | function urlBase(protocol, port, host) { |
| 37 | + // A little bit of funky here. It is possible that ONOS sits behind a proxy | ||
| 38 | + // and has an app prefix, e.g. http://host:port/my/app/onos/ui... This bit | ||
| 39 | + // of regex grabs everything after the host:port and before the uiContext | ||
| 40 | + // (/onos/ui/) and uses that as an app prefix by inserting it back into | ||
| 41 | + // the WS URL, if no prefix, then no insert. | ||
| 42 | + var prefix = "" | ||
| 43 | + if ($loc.absUrl) { | ||
| 44 | + var p = $loc.absUrl().match(".*//[^/]+/(.+)"+uiContext); | ||
| 45 | + prefix = p ? '/' + p[1] : ''; | ||
| 46 | + } | ||
| 47 | + | ||
| 37 | return matchSecure(protocol) + '://' + | 48 | return matchSecure(protocol) + '://' + |
| 38 | - (host || $loc.host()) + ':' + (port || $loc.port()); | 49 | + (host || $loc.host()) + ':' + (port || $loc.port()) + prefix; |
| 39 | } | 50 | } |
| 40 | 51 | ||
| 41 | function httpPrefix(suffix) { | 52 | function httpPrefix(suffix) { | ... | ... |
-
Please register or login to post a comment