So i was working on trying to make a post request, which was hosted on Azure Funciton Apps, from from Microsof Teams. So i came across with following error
Access to XMLHttpRequest at <URL> from origin ‘https://<tenant>.sharepoint.com’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
My solution comprises of following bits
- Azure Funciton Apps
One point to note over here in my case, my function app hosted on different tenant and teams application is hosted on other tenant. Furthermore i have registered Azure Function App in teams application tenant.
After digging in bit deep, i found out in the App Registration there is a settings for
As i mentioned above my Function App hosted on different Azure directory, once i chose the the other option (multitenant one). it resolved the issue.
Well it seems that above update doesnt resolve the issue itself. There is CORS settings in the App settings for Azure Function. Once you provide the url, access this Azure Functions in the Allowed Origins, plus the request credentials based on how you setup the credential.
You can skip the above setting, you can setup the request with the following settings, Following is the example to enable CORS from the NodeJS Azure Functions