From 03c5201d51d4861fa0412bf4a3e3524d9cb4b367 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Thu, 4 Aug 2022 14:54:32 +0100 Subject: [PATCH] Made koenig-react async import protocol agnostic no issue - when running locally with local development version of koenig-react without any proxies we were previously forcing `https://` even if the specific url in config was `http://` meaning a proxy was required - switched to allowing both http and https urls in config --- ghost/admin/app/components/koenig-react-editor.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ghost/admin/app/components/koenig-react-editor.js b/ghost/admin/app/components/koenig-react-editor.js index 0fea1ed9ca..f0bee9bcea 100644 --- a/ghost/admin/app/components/koenig-react-editor.js +++ b/ghost/admin/app/components/koenig-react-editor.js @@ -30,12 +30,17 @@ const fetchKoenig = function () { return window.koenigEditor.default; } - // the removal of `https://` and it's manual addition to the import template string is + // the manual specification of the protocol in the import template string is // required to work around ember-auto-import complaining about an unknown dynamic import // during the build step const GhostAdmin = window.Ember.Namespace.NAMESPACES.find(ns => ns.name === 'ghost-admin'); - const url = GhostAdmin.__container__.lookup('service:config').get('editor.url').replace('https://', ''); - await import(`https://${url}`); + const url = new URL(GhostAdmin.__container__.lookup('service:config').get('editor.url')); + + if (url.protocol === 'http:') { + await import(`http://${url.host}${url.pathname}`); + } else { + await import(`https://${url.host}${url.pathname}`); + } return window.koenigEditor.default; };