Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsafe attempt to load URL (SVG) #21

Closed
eyaleizenberg opened this issue Jan 19, 2016 · 8 comments
Closed

Unsafe attempt to load URL (SVG) #21

eyaleizenberg opened this issue Jan 19, 2016 · 8 comments

Comments

@eyaleizenberg
Copy link
Contributor

Hi,
When I'm trying to use the DropdownButton in the SF env, I am getting the following error:

Unsafe attempt to load URL https://MYDOMAIN-dev-ed.my.salesforce.com/assets/icons/utility-sprite/svg/symbols.svg#down from frame with URL https://MYDOMAIN-dev-ed.lightning.force.com/c/main.app. Domains, protocols and ports must match.

Obviously this is a CORS issue. The question is how I fix it in this case?

Thanks.

@rjmah
Copy link
Contributor

rjmah commented Jan 19, 2016

Since my asset folder is a static resource zip, I'm using utils.setAssetRoot() to set the correct asset path. I have to set the assetRoot as a global variable in VF so that I can use it in my webpack bundle.

In my VF page:

<script type="text/javascript">
    window.assetRoot = "{!URLFOR($Resource.SLDS)}";
</script>

And in my webpack entry file:

import { util } from 'react-lightning-design-system';
util.setAssetRoot(window.assetRoot);

@stomita
Copy link
Collaborator

stomita commented Jan 20, 2016

Yes, util.setAssetRoot() is the way to tell the resource location.

@stomita stomita closed this as completed Jan 20, 2016
@eyaleizenberg
Copy link
Contributor Author

Works! Thanks!

@eyaleizenberg
Copy link
Contributor Author

By the way I am faced with a very similar issue when trying to run my app in the SF environment. The issue is now in the CSS when it's looking for the fonts. Suggestions? @stomita @rjmah

@eyaleizenberg
Copy link
Contributor Author

I was able to work around the issue by changing the paths to /resource/assets....

However I have noticed that some of the styles are being overridden, specifically the font. Until I remove some other .css includes from the head, my font doesn't catch on...

@rjmah
Copy link
Contributor

rjmah commented Jan 21, 2016

@eyaleizenberg

Not sure what your setup is but here is what I'm doing with the lightning design system zip file as a static resource:

<apex:page standardStylesheets="false" applyBodyTag="false" sidebar="false">
<apex:stylesheet value="{!URLFOR($Resource.SLDS, 'assets/styles/salesforce-lightning-design-system-vf.css')}" />
<div class="slds">
...
  • Make sure your static resource contains the SalesforceSans font in resource/assets/fonts.
  • I need to apply the "slds" class to my div because I am still showing my aloha header. Otherwise, I'll get a CSS clash for my header.
  • ...-vf.css is the version of css that scopes the lightning css to whatever is in the "slds" classed element.

@eyaleizenberg
Copy link
Contributor Author

Yup looks like I was missing the -vf.css

Thanks a lot @rjmah !

@rjmah
Copy link
Contributor

rjmah commented Jan 21, 2016

Glad it worked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants