4

Static resources aren't loading when my Lightning Component is hosted on a Customer Community page. They do load in-app, so I'm guessing there's a namespace issue with my resource paths when I use the component in Community.

On page load the following resources fail to load in the live community site, whose url is https://mycarexchange-developer-edition.na53.force.com/s/, but do load in-app as well as in Community Builder Preview.

<ltng:require styles="{!$Resource.Leaflet +'/leaflet.css'}" 
              scripts="{!$Resource.Leaflet +'/leaflet-src.js'}"
              afterScriptsLoaded="{!c.jsLoaded}" />

The errors were,

Refused to apply style from 'https://mycarexchange-developer-edition.na53.force.com/resource/1534109270000/Leaflet/leaflet.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled. VM40579:1

GET https://mycarexchange-developer-edition.na53.force.com/resource/1534109270000/Leaflet/leaflet-src.js 404 (Not Found)

The Leaflet folder structure is as follows (image is the only folder in this zip, the rest are files)
Leaflet.zip
--leaflet.css
--leaflet.js
--leaflet.js.map
--leaflet-src.js.map
--leaflet-src.js
--images
----image files

Unfortunately I'm having this same issue with most of my static resources; I didn't include all examples for brevity, but will do so if it's helpful.

  • what about permissions to your static resource? set it's Cache Control to Public – Itai Shmida Aug 15 '18 at 7:18
  • @ItaiShmida That did the trick. Thank you. Can you submit as an answer so I can mark this question as 'answered'? – Nicholas Zozaya Aug 16 '18 at 1:57
  • Also, I've found that quitting and reopening chrome sometimes solves this issue, especially when hosting components in communities. Seems like there's caching going on that causes sporadic issues with loading static resources. – Nicholas Zozaya Aug 18 '18 at 6:28
1

You need to set the static resource Cache Control as Public:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.