Fixed loading CDN assets via lazy loading

refs https://github.com/TryGhost/DevOps/issues/47

- in the event we supply a CDN URL, don't prefix the URL with anything
  as this will get auto-prefixed
- if not, add the Ghost Admin root because the assets sit under there
This commit is contained in:
Daniel Lockyer 2023-07-17 13:44:50 +02:00 committed by Daniel Lockyer
parent 97f24338bf
commit 67a8244811

View File

@ -35,7 +35,7 @@ export default class LazyLoaderService extends Service {
let script = document.createElement('script');
script.type = 'text/javascript';
script.async = true;
script.src = `${config.cdnUrl || this.ghostPaths.adminRoot}${url}`;
script.src = `${config.cdnUrl ? '' : this.ghostPaths.adminRoot}${url}`;
let el = document.getElementsByTagName('script')[0];
el.parentNode.insertBefore(script, el);
@ -63,7 +63,7 @@ export default class LazyLoaderService extends Service {
let link = document.createElement('link');
link.id = `${key}-styles`;
link.rel = alternate ? 'alternate stylesheet' : 'stylesheet';
link.href = `${config.cdnUrl || this.ghostPaths.adminRoot}${url}`;
link.href = `${config.cdnUrl ? '' : this.ghostPaths.adminRoot}${url}`;
link.onload = () => {
link.onload = null;
if (alternate) {