Skip to content

MWPW-191633: Enable milolibs/unitylibs query params on CC stage URLs#754

Open
nkthakur48 wants to merge 5 commits intoadobecom:stagefrom
nkthakur48:MWPW-191633-support-unitylibs-stage
Open

MWPW-191633: Enable milolibs/unitylibs query params on CC stage URLs#754
nkthakur48 wants to merge 5 commits intoadobecom:stagefrom
nkthakur48:MWPW-191633-support-unitylibs-stage

Conversation

export function decorateArea() {}

const miloLibs = setLibs('/libs');
const miloLibs = setLibs(`${window.location.origin}/libs`);
Copy link
Copy Markdown
Author

@nkthakur48 nkthakur48 Apr 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explanation for this change:
unitylibs/scripts/utils.js is consumed cross-origin — when a project like da-cc loads it from a custom unity branch, the file is served from https://my-branch--unity--adobecom.aem.live. In ES modules, a root-relative path like /libs resolves against the module's origin, not the page's origin. So import('/libs/utils/utils.js') was hitting https://my-branch--unity--adobecom.aem.live/libs/utils/utils.js - a 404.

This only became visible after the stage fix: on .aem./.hlx. hosts, setLibs already returns an absolute Milo URL, so module origin doesn't matter. On stage with branch === 'main', it now falls through and returns the relative prodLibs = '/libs', which exposed the bug.

Passing ${window.location.origin}/libs instead makes prodLibs an absolute URL anchored to the page's origin, so the import always resolves correctly regardless of where the module was loaded from.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants