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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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.

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

July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.


Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.