Externalize a URL from a clientlibs script
Hi all,
Is it possible to access resource mappers and also externalize URLs from a clientlibs javascript that runs on clients browser?
Hi all,
Is it possible to access resource mappers and also externalize URLs from a clientlibs javascript that runs on clients browser?
Hi @aemamateur ,
The Externalizer or any resource resolver functions are accessible only in the server side, and the Javascript or clientlibs won't have any visibility to them.
For your usecase of externalising or shortening the AEM full urls received from a third party, following could be possible solutions:
1. Update the Source (Preferred) : Update the data at the third party with the AEM shortened/externalised URLs and use them as is. Afterall, we wouldn't want to expose the AEM full content paths to a third party, and that should solve your problem, as well as for any other downstream systems using the same third party service.
2. Wrapper Servlet: If 1 is not possible, Have a servlet in AEM that could accept a set of urls as input and return the corresponding shortened URLs. Invoke this servlet in your JS and use the output.
3. JS Utility (Temporary): Have a custom JS utility that replicates the logic of externalise/shortening and use it in your clientlibs. This however will involve maintenance, if there is any update to your logic at server side.
Thanks!
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.