When I try to access salesforce lightning components in AEM, I was not able to access the lightning script from AEM server, I got below error in browser console.
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin'
header is present on the requested resource. Origin 'https://localhost:5544' is therefore not allowed access.
Issue:
XMLHttpRequest cannot load https://AAAAAA.lightning.force.com/lightning/lightning.out.js.Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin'
header is present on the requested resource. Origin 'https://localhost:5544' is therefore not allowed access.
Solution:
We need to whitelist the origin i.e. our aem server in salesforce.
- Goto salesforce.com site, click on Setup -> search for CORS
- Goto CORS console, give the AEM server url pattern, in my case it is https://localhost:5544