From e5c8a47cbb39dddb0855c1ddfa505f083fff0c78 Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Thu, 8 Feb 2018 15:36:11 -0600 Subject: [PATCH] fix monaco editor config to ensure service workers are not loaded from cross-domain origins --- app/assets/javascripts/ide/monaco_loader.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/assets/javascripts/ide/monaco_loader.js b/app/assets/javascripts/ide/monaco_loader.js index af83a1ec0b4..142a220097b 100644 --- a/app/assets/javascripts/ide/monaco_loader.js +++ b/app/assets/javascripts/ide/monaco_loader.js @@ -6,6 +6,11 @@ monacoContext.require.config({ }, }); +// ignore CDN config and use local assets path for service worker which cannot be cross-domain +const relativeRootPath = (gon && gon.relative_url_root) || ''; +const monacoPath = `${relativeRootPath}/assets/webpack/monaco-editor/vs`; +window.MonacoEnvironment = { getWorkerUrl: () => `${monacoPath}/base/worker/workerMain.js` }; + // eslint-disable-next-line no-underscore-dangle window.__monaco_context__ = monacoContext; export default monacoContext.require;