0

We have created a small Lightning component in our Salesforce test org which will show the feeds from a chatter group we created (for testing purpose).

Also created a connected App in Salesforce to authenticate using OAuth2 for an external Web App.

For the moment we are testing using API development env POSTMAN.

Callback URL = https://www.getpostman.com/oauth2/callback (Using postman URL).

Login URL: https://ourinstance.my.salesforce.com

We have created a lightning application, lightning component and VF page as below:

VF Page

  <apex:page lightningStyleSheets="true" sidebar="false" showHeader="false">                  
      <apex:slds />
      <apex:includeLightning />
         <div id="lightning" />

            <script>
                 $Lightning.use("c:ChatterAMPortalApp", function() {         
                 $Lightning.createComponent("c:ChatterAMPortalComp",
                            { "sourceId" : "0F94E0000004eT2" }, // Chatter Group Id
                             "lightning",
                              function(cmp) {
                              // do some stuff
                               });
                            });
            </script>
   </apex:page>

Lightning App

  <aura:application access="GLOBAL"  extends="ltng:outApp"  implements="ltng:allowGuestAccess">
      <c:ChatterAMPortalComp />    
  </aura:application>

Lightning Component

  <aura:component access="GLOBAL" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes">
    <forceChatter:feed type="Record"  subjectId="0F94E0000004eT2"/> 
  </aura:component>

When we are trying to preview(https://ourInstance.force.com/apex/chatterAmVFPage) the vf page within the salesforce we are getting the outcome, but with the same preview URL inside postman, not getting any result. (Status is 200 OK)

Error:

Failed to load capgemini--devmaster.cs83.my.salesforce.com/?id=https://…: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'thor-chatter-test.dev.macs.capgemini.com'; is therefore not allowed access.

Note: We tried with another VF page without any lightning components and its working fine.

5
  • Failed to load capgemini--devmaster.cs83.my.salesforce.com/?id=https://…: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'thor-chatter-test.dev.macs.capgemini.com' is therefore not allowed access.
    – Brav
    Commented Jul 7, 2018 at 14:53
  • yup.. Whitelisted the domain in CORS...
    – Brav
    Commented Jul 7, 2018 at 15:02
  • Added the URLs in remote site setting but not aware of CSP.
    – Brav
    Commented Jul 7, 2018 at 15:04
  • No.. Still the same error..
    – Brav
    Commented Jul 7, 2018 at 15:17
  • Does this and this link help? I would imagine this is a CORS related issue where the request is made to the VF page being served from the VF context/resource and that your LC is served from a different context/resource.
    – Jayant Das
    Commented Jul 8, 2018 at 3:37

0

You must log in to answer this question.

Browse other questions tagged .