5

I have a global Visualforce component in the package I am developing that uses the following Static Resource to load fonts:

<apex:styleSheet value="{!URLFOR($Resource.ImagesAndJavascriptZip, '/css/fontFamilies.css')}"/>

When this component is used in pages within the package, the fonts render correctly. However, when the component is used in a custom Visualforce Page outside of the package, the fonts do not render correctly and the following error is thrown in the Chrome console:

Font from origin 'https://zqci06.na3.visual.force.com' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://c.na3.visual.force.com' is therefore not allowed access.

I have tried adding https://zqci06.na3.visual.force.com to the CORS Whitelist, but that still did not resolve the issue. Has anyone else encountered this problem?

4

You should try with the namespace of the package being added

lets assume your namespace is zqci06

then the way to access it will be as follows

<apex:styleSheet value="{!URLFOR($Resource.zqci06__ImagesAndJavascriptZip, '/css/fontFamilies.css')}"/>
| improve this answer | |
  • It shouldn't be this issue because the component is developed inside the package – Lance Shi Sep 15 '16 at 5:00
  • The issue happens when a page outside the package is referencing static resources in the package .So namespace could be one of the reasons . – Mohith Shrivastava Sep 15 '16 at 5:02
  • How can I dynamically add the package namespace to the URLFOR command? I ask because my managed package can have different namespaces depending on whether it is a Beta package or a Released package. – Suryatej Mukkamalla Sep 15 '16 at 5:17
  • First question is did this solved your problem ? Or do you still see CORS error – Mohith Shrivastava Sep 15 '16 at 5:19
  • You can create a custom setting that's not protected and use post install script to populate namespace if your BETA and released packages are name spaced different – Mohith Shrivastava Sep 15 '16 at 5:24
0

I have filed a ticket with Salesforce support and their response is that this is a known issue occurring with some customers using the Chrome browser. I am waiting to hear back about when they are planning to deploy the fix.

| improve this answer | |
  • Did you try with hardcoded namespace to see if it fixes ? – Mohith Shrivastava Sep 15 '16 at 19:05
0

As this is an known issue for Salesforce, and we know that it might take years for them to make a deployment for the fix, I would suggest you to take a walkaround for this issue.

One simple way to do this is in your page outside the package, add this line of code:

<apex:styleSheet value="{!URLFOR($Resource.YOURNAMESPACE__ImagesAndJavascriptZip, '/css/fontFamilies.css')}"/>

Assuming your resource is public, it should work fine for you.

| improve this answer | |

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.