Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Swetasannbommaj
New Member

Facing CORS issue when Embeding Power BI in Salesforce Org

Hello Team,

 

Facing issue while calling loginPopup() api and getting error CORS.

Need immidiate Solution.

Swetasannbommaj_0-1722235907769.png

 

1 REPLY 1
Anonymous
Not applicable

Hi,@Swetasannbommaj 

Regarding the issue you raised, my solution is as follows:

1.First, you can try to install and enable CORS on the gateway API side with the following command:

npm install cors

Multiple routing files:

const express = require("express");
const router = express.Router();
const cors = require("cors");
router.use(cors());

Single route file:

const express = require("express")
const app = express()
const cors = require("cors")
app.use(cors())

Below are links to related questions:
javascript - React component has been blocked by CORS policy: No 'Access-Control-Allow-Origin' heade...

Here is a link to enable CORS on the gateway API side:
CORS for REST APIs in API Gateway - Amazon API Gateway
 

2.Second, you can also redefine the headers and return:
 

const headers = {'Content-Type':'application/json',
                    'Access-Control-Allow-Origin':'*',
                    'Access-Control-Allow-Methods':'POST,PATCH,OPTIONS'}
const response = {
    statusCode: 200,
    headers:headers,
    body: JSON.stringify(X),
};
return response;

Here are the links to related questions:
aws lambda - Access to fetch at '' from origin '' has been blocked by CORS policy: No 'Access-Contro...
 

3.Finally, you can also try adding mode: 'no-cors' to the fetch method:

fetch(clientConfiguration['communitiesApi.local'], {
    mode: 'no-cors'
  })
  .then((response) => {
      return response.json();                
  })
  .then(data => {
      console.log(data);
      let communitiesFromApi = data.map(community => { return { value: community, display: community } });
      this.setState({ communities: [{ value: '', display: 'Select a Community...' }].concat(communitiesFromApi) });    

  }).catch(error => {
      console.log(error);
  });

 

Here are the links to related questions:

 javascript - React component has been blocked by CORS policy: No 'Access-Control-Allow-Origin' heade...

Of course, if you have any new ideas, you are welcome to contact us.
 

Best Regards,

Leroy Lu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.