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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
NaveenB
New Member

Custom visuals are not rendering due to a CORS error while making an API call

We are getting a CORS (cross-origin resource sharing) error while calling an API from a Power BI custom visual. We are getting this error from only one domain, both in the Power BI Service and on the Desktop.
(Error: Access to XMLHttpRequest at 'xxxxxx' from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource).

We checked this custom visual in other domains of the Power BI service, API calls were successful, and the visual is rendering as expected.

We checked that ‘Access-Control-Allow-Origin’ as ‘*’ is enabled in the API call header and in the Backend as well.

Please let us know if we need to change any settings in Power BI to overcome this issue or if there is any other approach for resolving the issue.

1 REPLY 1
Adamboer
Responsive Resident
Responsive Resident

The CORS error occurs when a web application makes a request to a resource on a different domain or port. In this case, the API endpoint you are trying to access is not allowing access from the domain you are using in the Power BI visual.

To resolve this issue, you need to configure the API to allow access from the domain or origin where your Power BI visual is hosted. You can do this by adding the domain or origin to the 'Access-Control-Allow-Origin' header in the API response.

Additionally, you can try to add the following header in the API response to allow credentials (if needed):

'Access-Control-Allow-Credentials': 'true'

If the issue still persists, you can try enabling the 'Allow any embedding' option in the Power BI report settings. This will allow the visual to load from any domain without any restrictions.

To enable this option, go to the report settings in the Power BI Service and under the 'Security' tab, toggle the 'Allow any embedding' option to 'On'.

Please note that enabling this option can pose security risks, so use it carefully and only if necessary.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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