Share via

Azure AD B2C CrossOriginException despite CORS being configured

Chris Beer 0 Reputation points
2025-01-22T12:18:04.0633333+00:00

Hi all

We are seeing a significant number of exceptions being logged to App Insights by our Azure AD B2C custom policies.

Microsoft.Cpim.UserExperience.Client.CrossOriginException

The resource 'https://xxx/xxx.html' contains script errors preventing it from being loaded.

The issue seems to be intermittent as the vast majority of users are able to sign in successfully. We can see a similar error message in the logs of some of our relying parties, indicating it is being sent in the response by Azure AD B2C, so seems likely that this manifests as a visible issue when it occurs.

Our UI templates are hosted in a storage account, and the CORS policy is configured as per Microsoft documentation. We have also confirmed that the templates do not contain any script errors.

Having reviewed the obvious things and having no success we are now left scratching our heads. If anyone is able to offer any insights on what might be the potential cause these would be gratefully received.

Thanks in advance.

Microsoft Security | Microsoft Entra | Microsoft Entra External ID

1 answer

Sort by: Most helpful
  1. Soos Ramírez 0 Reputation points
    2025-04-07T15:40:36.88+00:00

    We encountered this issue and found it was due to a Private Endpoint Connection on the Storage Account hosting our static content.

    An nslookup on our Storage Account URI resolved two aliases:
    Aliases:  xxxxx.blob.core.windows.net
              xxxxx.privatelink.blob.core.windows.net

    If someone tried to load our login page from a network with its own Azure privatelink resolver, their browser would attempt to load our content from their own tenant.

    We resolved this by deleting the private endpoint connection (found under Security + Networking > Networking > Private Endpoint Connections in the Storage Account Console). This immediately stopped the ClientCrossOriginException messages. If you need the private endpoint, make sure the privatelink alias doesn't appear in DNS outside your network.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.