Unexpected hostRoot detection and missing “Page” node in Universal Editor content tree (EDS + Franklin) | Community
Skip to main content
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!

 

 

 

3 replies

SantoshSai
Community Advisor
Community Advisor
June 13, 2025

Hi @olsalas711,

Could you try below and see if helps?:

  • Force relative script URLs in your templates so hlx.codeBasePath always resolves relative to author origin.

  • In your Franklin config, explicitly set authorServiceEndpoint to your Author URL.

  • Review your Dispatcher / CDN rules to avoid rewriting author URLs to Edge URLs during authoring sessions.

  • Add or correct /etc/map resource mappings for author URLs so path detection works correctly.

  • Consider adding a runtime override in your setup() function to force hlx.codeBasePath if needed:

window.hlx.codeBasePath = '/content/my-site.resource';  // force correct base path during author
Santosh Sai
AmitVishwakarma
Community Advisor
Community Advisor
June 16, 2025

Hi @olsalas711 ,

Root Causes

 - Absolute URLs in HTML templates or injected via JS.

 - Script origin mismatch (Edge URL being picked instead of local /content/... path).

 - No Page node appears in Universal Editor due to improper hostRoot resolution.

 - Missing or incorrect authorServiceEndpoint config in config.json.

Try below soutions:

 

1. Force Relative Script Path in Template

Make sure your HTML includes the script as a relative path (not absolute or Edge-prefixed):

<!-- GOOD --> <script src="/scripts/scripts.js" type="module"></script> <!-- BAD --> <script src="https://ue-site.edge.page/scripts/scripts.js"></script>

Why: This ensures window.hlx.codeBasePath correctly resolves to /content/site.resource on the author instance.

 

2. Force codeBasePath in setup() during Authoring

Update your setup() function with a check for author environment:

function setup() { window.hlx = window.hlx || {}; window.hlx.RUM_MASK_URL = 'full'; window.hlx.RUM_MANUAL_ENHANCE = true; window.hlx.codeBasePath = ''; const scriptEl = document.querySelector('script[src$="/scripts/scripts.js"]'); if (scriptEl) { try { 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) { console.log(error); } } // Force override in Author environment if (window.location.hostname.includes('author') || window.location.hostname.includes('aem.author')) { window.hlx.codeBasePath = '/content/my-site.resource'; } console.log('hlx.codeBasePath:', window.hlx.codeBasePath); }

3. Set authorServiceEndpoint in config.json

Ensure your config.json includes the correct author URL so Universal Editor connects properly:

{ "authorServiceEndpoint": "https://author-pxxxx-adobeaemcloud.com" }

4. Check /etc/map.publish and /etc/map.author

Ensure mappings don’t rewrite or redirect requests in a way that confuses Universal Editor or CORS:

  - Author /content/my-site.resource => should not be rewritten to Edge domain.

  - Fix any incorrect Dispatcher rewrites for .resource paths.

 
Regards,
Amit

kautuk_sahni
Community Manager
Community Manager
June 23, 2025

@olsalas711 Did you find the suggestions helpful? If you need more information, please let us know. If a response resolved your issue, kindly mark it as correct to help others in the future. Alternatively, if you discovered a solution on your own, we'd appreciate it if you could share it with the community. Thank you.

Kautuk Sahni