diff --git a/packages/kbn-interpreter/src/public/browser_registries.js b/packages/kbn-interpreter/src/public/browser_registries.js index 778a0b03a7624..312c934cdedec 100644 --- a/packages/kbn-interpreter/src/public/browser_registries.js +++ b/packages/kbn-interpreter/src/public/browser_registries.js @@ -17,7 +17,6 @@ * under the License. */ -import chrome from 'ui/chrome'; import $script from 'scriptjs'; let resolvePromise = null; @@ -31,7 +30,7 @@ export const getBrowserRegistries = () => { return populatePromise; }; -const loadBrowserRegistries = (registries) => { +const loadBrowserRegistries = (registries, basePath) => { const remainingTypes = Object.keys(registries); const populatedTypes = {}; @@ -47,7 +46,7 @@ const loadBrowserRegistries = (registries) => { // Load plugins one at a time because each needs a different loader function // $script will only load each of these once, we so can call this as many times as we need? - const pluginPath = chrome.addBasePath(`/api/canvas/plugins?type=${type}`); + const pluginPath = `${basePath}/api/canvas/plugins?type=${type}`; $script(pluginPath, () => { populatedTypes[type] = registries[type]; loadType(); @@ -58,7 +57,7 @@ const loadBrowserRegistries = (registries) => { }); }; -export const populateBrowserRegistries = (registries) => { +export const populateBrowserRegistries = (registries, basePath) => { if (called) { const oldPromise = populatePromise; let newResolve; @@ -66,7 +65,7 @@ export const populateBrowserRegistries = (registries) => { newResolve = _resolve; }); oldPromise.then(oldTypes => { - loadBrowserRegistries(registries).then(newTypes => { + loadBrowserRegistries(registries, basePath).then(newTypes => { newResolve({ ...oldTypes, ...newTypes, @@ -76,7 +75,7 @@ export const populateBrowserRegistries = (registries) => { return populatePromise; } called = true; - loadBrowserRegistries(registries).then(registries => { + loadBrowserRegistries(registries, basePath).then(registries => { resolvePromise(registries); }); return populatePromise; diff --git a/src/core_plugins/interpreter/public/load_browser_plugins.js b/src/core_plugins/interpreter/public/load_browser_plugins.js index 6034dae00238c..de550f5c6a351 100644 --- a/src/core_plugins/interpreter/public/load_browser_plugins.js +++ b/src/core_plugins/interpreter/public/load_browser_plugins.js @@ -17,6 +17,7 @@ * under the License. */ +import chrome from 'ui/chrome'; import { populateBrowserRegistries } from '@kbn/interpreter/public'; import { typesRegistry, functionsRegistry } from '@kbn/interpreter/common'; @@ -26,4 +27,4 @@ const types = { types: typesRegistry }; -populateBrowserRegistries(types); +populateBrowserRegistries(types, chrome.getBasePath()); diff --git a/x-pack/plugins/canvas/public/components/app/index.js b/x-pack/plugins/canvas/public/components/app/index.js index 6fc4a107f719a..f5fc65e029f36 100644 --- a/x-pack/plugins/canvas/public/components/app/index.js +++ b/x-pack/plugins/canvas/public/components/app/index.js @@ -53,7 +53,7 @@ const mapDispatchToProps = dispatch => ({ // initialize the socket and interpreter await createSocket(basePath); loadPrivateBrowserFunctions(); - await populateBrowserRegistries(types); + await populateBrowserRegistries(types, basePath); await initializeInterpreter(); // set app state to ready