Level 4
June 13, 2025
Unexpected hostRoot detection and missing “Page” node in Universal Editor content tree (EDS + Franklin)
- June 13, 2025
- 3 replies
- 478 views
Hello Community,
I have two AEM sites (AEM as cloud service Author + Edge Delivery Service with Franklin/EDS template) set up almost identically, but I’m seeing two puzzling differences:
1. hostRoot / codeBasePath detection:
function setup() {
window.hlx = window.hlx || {};
window.hlx.RUM_MASK_URL = 'full';
window.hlx.RUM_MANUAL_ENHANCE = true;
window.hlx.codeBasePath = '';
window.hlx.lighthouse = new URLSearchParams(window.location.search).get('lighthouse') === 'on';
const scriptEl = document.querySelector('script[src$="/scripts/scripts.js"]');
if (scriptEl) {
try {
console.log('👉 hlx.codeBasePath scriptEl.src:', scriptEl);
const scriptURL = new URL(scriptEl.src, window.location);
if (scriptURL.host === window.location.host) {
[window.hlx.codeBasePath] = scriptURL.pathname.split('/scripts/scripts.js');
} else {
[window.hlx.codeBasePath] = scriptURL.href.split('/scripts/scripts.js');
}
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
}
}
// <<< aquí pones tu console.log temporal >>>
console.log('👉 hlx.codeBasePath al arrancar:', window.hlx.codeBasePath);
}
Site A (works): In the Universal Editor console I see:
👉 hlx.codeBasePath scriptEl.src: <script src="/content/my-site.resource/scripts/scripts.js" …>
👉 hlx.codeBasePath on startup: /content/my-site.resource
Site B (broken): I instead get:
👉 hlx.codeBasePath scriptEl.src: <script src="https://ue-...aem.page/scripts/scripts.js" …>
👉 hlx.codeBasePath on startup:
In Site B it always picks the Edge URL, not the Author origin, which causes CORS failures in the editor.
Are there any known Franklin/EDS template settings or author-service-endpoint parameters that could cause this discrepancy?
Any pointers, examples, or configuration snippets would be greatly appreciated!