Skip to content

Commit bc2ee31

Browse files
waldekmastykarzVesaJuvonen
authored andcommitted
Added notes regarding CORS configuration for APIs hosted on Azure (SharePoint#1783)
* Added notes regarding CORS configuration for APIs hosted on Azure * Updated title of the article on using the AadHttpClient
1 parent f0ae262 commit bc2ee31

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

docs/spfx/use-aadhttpclient-enterpriseapi.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ On the Azure AD application blade, copy the value of the **Application ID** prop
183183

184184
The Function App will be called from JavaScript running on a SharePoint page. Because the API is hosted on a different ___domain than the SharePoint portal, cross-___domain security constraints will apply to the API call. By default, APIs implemented using Azure Function Apps cannot be called from other domains. You can change this by adjusting the Function App's CORS settings.
185185

186+
> [!IMPORTANT]
187+
> If you're authenticating with the API using the SharePoint Online cookie instead of OAuth, you cannot configure CORS settings through the Azure Portal. For the authentication to work, you have to clear all CORS settings in the Azure Portal and specify them in your API instead.
188+
186189
In the Function App, switch to the **Platform features** tab.
187190

188191
From the **API** group, select the **CORS** link:

docs/spfx/web-parts/guidance/connect-to-api-secured-with-aad.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,9 @@ Following is how you would use Azure Functions to create an API secured with Azu
324324

325325
Azure Functions are hosted in Azure App Service, which allows you to configure its Cross-Origin Resource Sharing (CORS) settings through the Azure Portal. While this is convenient, if configured through the portal, it cannot be used in combination with the **Access-Control-Allow-Credentials** header, which is required by the API to accept authentication cookies coming from another origin. For the client-side authentication to work correctly, CORS settings of the Azure App Service must be cleared.
326326

327+
> [!IMPORTANT]
328+
> If you're authenticating with the API using the SharePoint Online cookie you have to clear all CORS settings or the authentication process will fail. If you're however authenticating using OAuth, you can use the Azure Portal, to configure CORS settings for your API.
329+
327330
1. In the Function App, select your Azure Function, and navigate to the **Platform features** blade.
328331

329332
![The Platform features link highlighted in the Azure Function settings](../../../images/api-aad-platform-features.png)

docs/toc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
href: spfx/web-parts/guidance/connect-to-api-secured-with-aad.md
130130
- name: Call the Microsoft Graph API using OAuth
131131
href: spfx/web-parts/guidance/call-microsoft-graph-from-your-web-part.md
132-
- name: Connect to Azure AD-secured APIs
132+
- name: Connect to APIs secured with Azure AD using the AadHttpClient
133133
href: spfx/use-aadhttpclient.md
134134
items:
135135
- name: Consume enterprise APIs (tutorial)

0 commit comments

Comments
 (0)