Unable to read images when using clientlib with allowproxy

Avatar

Avatar

rohitn62196663

Avatar

rohitn62196663

rohitn62196663

24-05-2018

I have created a clientlib and I have included it within the apps->projectname->components->component->clientlibs. As per adobe recommendation I have added allowproxy=true property so that its not exposed directly from the apps folder. When I load the clientlibs its loading from etc.clientlibs and it works fine. But now I have added some images within the clientlibs folder and I have referred those image url's in my css file. I have provided the relative path of the images. However when the page loads its not loading the images. The image url is starting with /etc.clienlibs/imagepath. When I change it to the the absolute url i.e. apps/imagepath in dev tools it works fine. But we should not be exposing directly the apps url rite. If thats the case how to load images via etc.clientlibs ?

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Arun_Patidar

MVP

Total Posts

3.0K

Likes

1.1K

Correct Reply

861

Avatar

Arun_Patidar

MVP

Total Posts

3.0K

Likes

1.1K

Correct Reply

861
Arun_Patidar
MVP

24-05-2018

A static resource can only be accessed via the proxy, if it resides in a resources folder like a resource below the client library folder.

As an example:

  • You have a clientlib in /apps/myproject/clientlibs/foo
  • You have a static image in /apps/myprojects/clientlibs/foo/resources/icon.png

Then you set the allowProxy property on foo to true.

  • You can then request /etc.clientlibs/myprojects/clientlibs/foo.js
  • You can then reference the image via /etc.clientlibs/myprojects/clientlibs/foo/resources/icon.png

Answers (3)

Answers (3)

Avatar

Avatar

rohitn62196663

Avatar

rohitn62196663

rohitn62196663

24-05-2018

I have read the clientlibs article before but never thought the folder name itself should be 'resources'.

Thanks for the information.

Avatar

Avatar

rohitn62196663

Avatar

rohitn62196663

rohitn62196663

24-05-2018

Is it mandatory to declare the folder name as resources. Under the clientlib folder I have created a folder with name as 'img' and it didn't work. But when I changed the name of the folder to resources it started working

Avatar

Avatar

Arun_Patidar

MVP

Total Posts

3.0K

Likes

1.1K

Correct Reply

861

Avatar

Arun_Patidar

MVP

Total Posts

3.0K

Likes

1.1K

Correct Reply

861
Arun_Patidar
MVP

24-05-2018

Hi,

Yes , if you set the allowProxy property

Using Client-Side Libraries