Why does AEM force us to place fonts under clientlib/resources/fonts ? | Community
Skip to main content
May 25, 2023
Solved

Why does AEM force us to place fonts under clientlib/resources/fonts ?

  • May 25, 2023
  • 2 replies
  • 966 views

We have a requirement in our project where we are using a 3rd party node_module in the ui.frontend module and packaging the css from that node module into a clientlib-site.

 

The css in that node module is such that it has references to font files with the path "../fonts/..." not "../../resources/fonts/"

Is there some way we can make the path /etc.clientlibs/<myproject>/clientlibs/clientlib-site/fonts/<font-filename>

 

Do we need to create our own proxy servlet for this ?

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

It forces you to do so because from dispatcher all nodes are not accessible to the end users as it will create a security issue. That’s why they have predefined the path where you can put your own custom code, js or css. If the reference fonts in outside of clientlibs the the problem might arise abs clientlibs are being called with proxy servlet /etc.clientlibs so your referenced fonts should also follow the same path with your default behaviour and with security concern you don’t want to open other paths for clientlibs 

2 replies

ManviSharma
Adobe Employee
Adobe Employee
May 25, 2023

Hi,

 

If you need to modify the path of the font files referenced in the CSS, you can consider creating a proxy servlet in your AEM project. The proxy servlet can intercept requests for the font files and rewrite the URLs to match the desired path, such as /etc.clientlibs/<myproject>/clientlibs/clientlib-site/fonts/<font-filename>.

DPrakashRaj
Community Advisor
DPrakashRajCommunity AdvisorAccepted solution
Community Advisor
May 25, 2023

It forces you to do so because from dispatcher all nodes are not accessible to the end users as it will create a security issue. That’s why they have predefined the path where you can put your own custom code, js or css. If the reference fonts in outside of clientlibs the the problem might arise abs clientlibs are being called with proxy servlet /etc.clientlibs so your referenced fonts should also follow the same path with your default behaviour and with security concern you don’t want to open other paths for clientlibs