Skip to content

Commit 97951f0

Browse files
authored
Update troubleshoot-cross-origin-resource-sharing-issues.md
1 parent af89c60 commit 97951f0

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

support/entra/entra-id/app-integration/troubleshoot-cross-origin-resource-sharing-issues.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
title: Troubleshoot Cross-Origin Resource Sharing issues
2+
title: Troubleshoot Cross-Origin Resource Sharing Issues
33
description: Helps you troubleshoot and resolve Cross-Origin Resource Sharing issues when using Microsoft Entra ID.
44
ms.service: entra-id
5-
ms.date: 07/04/2025
5+
ms.date: 07/07/2025
66
ms.reviewer: willfid, v-weizhu
77
ms.custom: sap:Developing or Registering apps with Microsoft identity platform
88
---
@@ -12,7 +12,7 @@ This article provides guidance on troubleshooting and resolving Cross-Origin Res
1212

1313
## Understanding CORS
1414

15-
[Cross-Origin Resource Sharing (CORS)](https://developer.mozilla.org/docs/Web/HTTP/Guides/CORS) is an [HTTP](https://developer.mozilla.org/docs/Glossary/HTTP)-header-based mechanism that allows a server to specify [origins](https://developer.mozilla.org/docs/Glossary/Origin)(domains, schemes, ports) other than its own from which a browser should permit loading resources. CORS also relies on a mechanism by which browsers make a "preflight" request to the server hosting the cross-origin resource, in order to check whether the server permits the actual request. During this preflight, the browser sends headers that indicate the HTTP method and headers that will be used in the actual request.
15+
[Cross-Origin Resource Sharing (CORS)](https://developer.mozilla.org/docs/Web/HTTP/Guides/CORS) is an [HTTP](https://developer.mozilla.org/docs/Glossary/HTTP)-header-based mechanism that allows a server to specify [origins](https://developer.mozilla.org/docs/Glossary/Origin)(domains, schemes, ports) other than its own from which a browser should permit loading resources. CORS also relies on a mechanism by which browsers make a "preflight" request to the server hosting the cross-origin resource, in order to check whether the server permits the actual request. During this preflight, the browser sends headers that indicate the HTTP method and headers that are used in the actual request.
1616

1717
For detailed information about CORS headers, refer to [CORS headers](https://developer.mozilla.org/docs/Glossary/CORS).
1818

@@ -41,7 +41,7 @@ While developing an application, you might encounter the following CORS-related
4141
> [!NOTE]
4242
>
4343
> - These errors are generated by Microsoft Entra ID. Request URLs in these errors often begin with `https://login.microsoftonline.com` or `https://<your-domain>.b2clogin.com`. The latter typically points to an Azure Active Directory B2C scenario.
44-
> - If the error doesn't originate from Microsoft Entra ID, it looks like "Access to XMLHttpRequest at `https://app.contoso.com`." This article doesn't provide guidance for resolving external CORS issues. In such cases, you need to configure CORS in that environment.
44+
> - If the error doesn't originate from Microsoft Entra ID, it looks like "Access to XMLHttpRequest at `https://app.contoso.com`." This article doesn't provide guidance on resolving external CORS issues. In such cases, you need to configure CORS in that environment.
4545
4646
## Cause
4747

@@ -91,15 +91,15 @@ You can notice that the request contains an `Origin` header, but no `Access-Cont
9191

9292
## General solution
9393

94-
Implement your application architecture to follow the OAuth2 and OIDC standards. This solution can ensure your front-end application acquires an access token and includes it in the `Authorization` header to the API you're making your `XMLHttpRequest` to. Here are some [single-page application samples](/entra/identity-platform/sample-v2-code?tabs=apptype).
94+
Implement your application architecture to follow the OAuth2 and OIDC standards. This solution can ensure your front-end application acquires an access token and includes it in the `Authorization` header of the request when you make your `XMLHttpRequest` to the API. Here are some [single-page application samples](/entra/identity-platform/sample-v2-code?tabs=apptype).
9595

9696
## Scenario-based solutions
9797

9898
Here are the most common scenarios. Not every scenario is listed in this article as every environment and app architecture is different.
9999

100100
### Scenario 1: Web app and Web API using authentication cookies
101101

102-
If your web app or framework makes `XMLHttpRequest` calls to its API endpoint and use the Web Apps authentication cookies, examine the `XMLHttpRequest` request in the Fiddler capture. It might look like this:
102+
If your web app or framework makes `XMLHttpRequest` calls to its API endpoint and uses the Web Apps authentication cookies, examine the `XMLHttpRequest` request in the Fiddler capture. It might look like this:
103103

104104
```http
105105
GET https://app.domain.com/… HTTP/1.1
@@ -133,7 +133,7 @@ If you use ASP.NET or ASP.NET Core, configure Microsoft Entra ID to avoid using
133133
}
134134
```
135135

136-
Then, implement extra `XMLHttpRequest` logic to check if the request is complete and it's a redirect or a 401 error. You must do this to tell the client to have the user sign-in again. In most cases, refreshing the page allows the user reauthenticate. Here's a code exmaple:
136+
Then, implement extra `XMLHttpRequest` logic to check if the request is complete and it's a redirect or a 401 error. You must perform the action to tell the client to have the user sign-in again. In most cases, refreshing the page allows the user to reauthenticate. Here's a code exmaple:
137137

138138
```http
139139
client.onreadystatechange = () => {
@@ -170,11 +170,11 @@ To resolve the issue in this scenario, use one of the following methods:
170170
171171
#### Method 1: Send a valid token
172172
173-
If you're passing an access token to your API resource, ensure the token is valid. Check if the token is expired. If it is, request a new access token. If you're using Microsoft Authentication Library for JavaScript (MSAL.js), use `acquireTokenSilent` every time to acquire a new token before passing it to your API. Don't cache this token yourself. Always use `acquireTokenSilent` to get the cached token directly from MSAL.
173+
If you pass an access token to your API resource, ensure the token is valid. Check if the token is expired. If it is, request a new access token. If you use Microsoft Authentication Library for JavaScript (MSAL.js), use `acquireTokenSilent` every time to acquire a new token before passing it to your API. Don't cache this token yourself. Always use `acquireTokenSilent` to get the cached token directly from MSAL.
174174
175175
For more information, see [Single-page application: Acquire a token to call an API](/entra/identity-platform/scenario-spa-acquire-token).
176176
177-
Here's is an example of how it looks when passing a token to an API: [Single-page application: Call a web API](/entra/identity-platform/scenario-spa-call-api)
177+
Here's is an example of how it looks when passing a token to an API: [Single-page application: Call a web API](/entra/identity-platform/scenario-spa-call-api).
178178
179179
#### Method 2: Use JWT bearer authentication
180180
@@ -218,7 +218,7 @@ Based on OAuth2 specs and Security best practices, don't use the following flows
218218
- Resource Owner Password Credential (ROPC)
219219
- Confidential Client flows, such as Client Credentials or On-behalf-of flows
220220
221-
All other flows won't be supported in Single Page Applications. Microsoft Entra ID and B2C won't add the CORS headers for the unsupported flows.
221+
All other flows aren't supported in Single Page Applications. Microsoft Entra ID and B2C don't add the CORS headers for the unsupported flows.
222222
223223
### Scenario 6: Using Microsoft Entra Application Proxy
224224
@@ -227,7 +227,7 @@ If your app uses Microsoft Entra Application Proxy, see [Understand complex appl
227227
## References
228228
229229
- [Enable Cross-Origin Requests (CORS) in ASP.NET Core](/aspnet/core/security/cors)
230-
- [Enabling Cross-Origin Requests in ASP.NET Web API 2](/aspnet/web-api/overview/security/enabling-cross-origin-requests-in-web-api)
230+
- [Enable Cross-Origin Requests in ASP.NET Web API 2](/aspnet/web-api/overview/security/enabling-cross-origin-requests-in-web-api)
231231
- [Azure App Service REST API tutorial](/azure/app-service/app-service-web-tutorial-rest-api)
232232
- [Azure API Management CORS policy](/azure/api-management/cors-policy)
233233

0 commit comments

Comments
 (0)