summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Greiling <mike@pixelcog.com>2018-02-08 15:36:11 -0600
committerMike Greiling <mike@pixelcog.com>2018-02-15 15:51:10 -0600
commite5c8a47cbb39dddb0855c1ddfa505f083fff0c78 (patch)
tree47c19ab348814137b3a7dc23ed0edc4bbfbd5449
parent4342e3915c9a3d374f3862b2cfc3ddb07ae56169 (diff)
downloadgitlab-ce-e5c8a47cbb39dddb0855c1ddfa505f083fff0c78.tar.gz
fix monaco editor config to ensure service workers are not loaded from cross-domain origins
-rw-r--r--app/assets/javascripts/ide/monaco_loader.js5
1 files changed, 5 insertions, 0 deletions
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;