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.