From 69e5488c139f249fcf785d4ba170a90ed0e7f33c Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 10 Jul 2019 13:30:52 +0200 Subject: [PATCH] luci-base: luci.js: fix undefined "this" when /ubus/ is unavailable Fixes: #2850 Fixes: 66dfe64ca ("luci-base: luci.js: cache determined RPC base url in session storage") Signed-off-by: Jo-Philipp Wich --- modules/luci-base/htdocs/luci-static/resources/luci.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/luci-base/htdocs/luci-static/resources/luci.js b/modules/luci-base/htdocs/luci-static/resources/luci.js index 3e40b304b6..1f883ab802 100644 --- a/modules/luci-base/htdocs/luci-static/resources/luci.js +++ b/modules/luci-base/htdocs/luci-static/resources/luci.js @@ -762,10 +762,12 @@ } if (rpcBaseURL == null) { + var rpcFallbackURL = this.url('admin/ubus'); + rpcBaseURL = Request.get('/ubus/').then(function(res) { - return (rpcBaseURL = (res.status == 400) ? '/ubus/' : this.url('admin/ubus')); + return (rpcBaseURL = (res.status == 400) ? '/ubus/' : rpcFallbackURL); }, function() { - return (rpcBaseURL = L.url('admin/ubus')); + return (rpcBaseURL = rpcFallbackURL); }).then(function(url) { try { window.sessionStorage.setItem('rpcBaseURL', url); -- 2.30.2