Static Resources not found by Customer Community Lightning Component

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.

Answer

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

enter image description here

Attribution
Source : Link , Question Author : Nicholas Zozaya , Answer Author : Itai Shmida

Leave a Comment