How to Set Dynamic Base Href for Clientlib Generated Using Angular SPA in AEM? | Community
Skip to main content
October 9, 2024
Question

How to Set Dynamic Base Href for Clientlib Generated Using Angular SPA in AEM?

  • October 9, 2024
  • 0 replies
  • 555 views

I'm trying to generate a clientlib for an Angular SPA in AEM using aem-clientlib-generator. By default, the baseHref (or deployUrl) for the resources folder in the clientlib is /etc.clientlibs/<proj-name>/clientlibs/clientlib-angular/resources.

This works fine in the local AEM environment (http://localhost:4502/). However, in other environments, we have paths like /auth or /pub after the host URL, e.g., https://aem-dev-url/auth or https://aem-dev-url/pub.

In these cases, the resources URL should become: https://aem-dev-url/auth/etc.clientlibs/<proj-name>/clientlibs/clientlib-angular/resources, depending on whether it's the auth or pub instance. How can I achieve this?

I tried configuring APP_BASE_HREF dynamically based on the URL in app.module.ts, setting it to /auth or /pub, but this doesn't work for accessing the resources folder in the generated clientlib.

How can I provide a dynamic base URL when generating the clientlib? Are there other methods to solve this?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.