4

I'm following the "Lightning Components Developer's Guide" and when I try to preview my app I get always a CSP (Content Security Policy) error that the css file is blocked for loading. I've read a similar question about it with REST API and Lightning Components How to call a Salesforce REST URL from Lightning Component? but is there another workaround then creating an APEX controller for loading just a css file?

2

Apex is not required and is not going to help for web content - you simply need to create a Static Resource in your org and upload the Bootstrap library. You can then reference /resource/yourBootstrapStaticResourceNameHere etc. Static Resources are served from the same domain as your app/components and therefore satisfy our CSP policy.

  • Here is a pattern to make sure things like font references work when Bootstrap is setup as a static resource. – Keith C Nov 26 '14 at 14:06
  • 1
    FYI: The Lightning Components Developer's Guide seems to indicate external CSS can be loaded: developer.salesforce.com/docs/atlas.en-us.lightning.meta/… – Peter Knolle Nov 26 '14 at 14:08
  • Thanks! I wrote resourc instead of resource in my code, now it' working! – Samuel Moyson Nov 26 '14 at 14:46
  • The LC Dev guide is derived from the Aura open source docs and this is a hold over from there that apparantly has not been adjusted to line up with Force.com's CSP enforcement. I've brought this to the LC doc folks attention and will get it corrected - thanks – Doug Chasman Nov 26 '14 at 15:40
  • And what about Lightning Tabs? Could it be that css is not working there? – Samuel Moyson Nov 28 '14 at 7:41

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.