0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

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
This commit is contained in:
Kevin Ansfield 2022-08-04 14:54:32 +01:00
parent bac8f4b8db
commit 03c5201d51

View file

@ -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;
};