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?

0

1 Answer 1

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.

6
  • Here is a pattern to make sure things like font references work when Bootstrap is setup as a static resource.
    – Keith C
    Nov 26, 2014 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/… Nov 26, 2014 at 14:08
  • Thanks! I wrote resourc instead of resource in my code, now it' working! Nov 26, 2014 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 Nov 26, 2014 at 15:40
  • And what about Lightning Tabs? Could it be that css is not working there? Nov 28, 2014 at 7:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .