Saturday, 9 June 2018

Access ClientLibs under apps folder through ClientLibraryProxyServlet

AEM provides ClientLibs feature to organize JS and CSS. Clientlibs can be created as 

  1. Approach 1: Place all files under /etc/designs/{project}/clientlibs path.
  2. Approach 2: Creating clientlibs under each component. Disadvantage with this approach is it increases number of calls to load clientlibs throuhout the page. This doesn't follow best practices as CSS will not be loaded in head section.
  3. Approach 3: Place clientlibs under /apps/project/. 
/apps folder is restricted to access by dispatcher. So we need to enable ClientLibraryProxyServlet  to access the clientlibs from apps folder.  Below are the steps to enable clientLibrary Proxy.

  • Create a new client library under /apps/... with new category. Let's say myapp.all
  • Add a embed property and  include all modular component library. (firstcomp,secondcomp)
  • Add boolean allowProxy = 'true'
  • On the headlibs.jsp include the above 
  • Then the clientlib will then be proxied via  there by passing access control set on the clientlib.

    • Configure dispatcher.any to allow for /etc.clientlibs/

No comments :

Post a Comment