You need to sign in to do that
Don't have an account?
Jaffer Ali.
Blocked by CORS policy error in javascript present in the visualforce page
Hello all,
I have whitelisted CORE orgin (https://maxcdn.bootstrapcdn.com) from salesforce but still getting the below error in javascript Console. If any one knows how to resolve it, then it would be great.
'https://maxcdn.bootstrapcdn.com/font-awesome/2.0/font//fontawesome-webfont.woff' from origin 'https://maxcdn.bootstrapcdn.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://c.cs5.visual.force.com' is therefore not allowed access. The response had HTTP status code 403.
Thats how Im reffering the bootstrapcdn.
<link href="https://netdna.bootstrapcdn.com/font-awesome/2.0/css/font-awesome.css" rel="stylesheet"/>
Thanks
Jaffer
I have whitelisted CORE orgin (https://maxcdn.bootstrapcdn.com) from salesforce but still getting the below error in javascript Console. If any one knows how to resolve it, then it would be great.
'https://maxcdn.bootstrapcdn.com/font-awesome/2.0/font//fontawesome-webfont.woff' from origin 'https://maxcdn.bootstrapcdn.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://c.cs5.visual.force.com' is therefore not allowed access. The response had HTTP status code 403.
Thats how Im reffering the bootstrapcdn.
<link href="https://netdna.bootstrapcdn.com/font-awesome/2.0/css/font-awesome.css" rel="stylesheet"/>
Thanks
Jaffer
This CORS issue is troubling many. I remember doing something with remote site settings. Not very sure but can you try adding your own domain, in this case,"https://lightningcheck-dev-ed--c.ap2.visual.force.com", in Remote Site Settings. It would make it an allowed domain to serve the request.
Another issue can be related to the Critical Update "Serve Static Resources from force.com domain", but I think this won't impact API calls. You can try to deactivate this update and check - in case you have installed this. - https://success.salesforce.com/issues_view?id=a1p300000008XRLAA2
Another option that I can think of is using Canvas SDK. It has built in cross domain proxies which can help resolve this issue. Refer https://developer.salesforce.com/docs/atlas.en-us.198.0.platform_connect.meta/platform_connect/canvas_app_xhr_intro.htm (https://developer.salesforce.com/docs/atlas.en-us.198.0.platform_connect.meta/platform_connect/canvas_app_xhr_intro.htm )
Instead, you can create a custom apex rest service and exposed it to a public site. Here is the blog post (https://developer.salesforce.com/blogs/developer-relations/2012/02/quick-tip-public-restful-web-services-on-force-com-sites.html" target="_blank) with an example on how to do that. As this was custom apex rest service, we were able to modify the response as required. Hence, in the custom code, we added a parameter 'access-control-allow-origin' in the response.
As our goal was to insert a record in the system and send back success or error result, the public apex rest service worked for us.
Kindly mark this post as solved if the information help's so that it gets removed from the unanswered queue and becomes a proper solution which results in helping others who are really in need of it.
Best Regards,
Nagendra.P
Thanks for your response. I tried to add the following in remote sites, but I am afraid nothing worked.
https://c.cs5.visual.force.com , https://cs5.salesforce.com,
https://maxcdn.bootstrapcdn.com and https://netdna.bootstrapcdn.com.
As this was working earlier some time back, I am just looking to update some code or config to make it working, instead of building some thing new from the scratch.
Thanks