Expand my Community achievements bar.

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

Avatar

Level 1

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?

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

0 Replies