I'm getting this error when I try to access azure web app(rest api) from a react app.
I modified web apps core to accept CORE origins from "*", but getting same error. But if I disable "Authentication / Authorization" option of azure web app then there is no errors like this. This only happens if I enabled "Authentication / Authorization" with an Azure AD app.
**Access to fetch at 'https://login.windows.net/XXXXXX/oauth2/authorize?response_type=id_token&redirect_uri=XXXXX' (redirected from 'https://AAAwebapp.azurewebsites.net/XXXXX') from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.*
I was able to resolve this issue. I modified my react app with below code .
const myHeaders = {}
const myInit = {
method: "GET",
headers: myHeaders,
credentials: "include"
}
and fetch part was modified with :
fetch('myapi url', myInit)
After that enabled Access-Control-Allow-Credentials of the Azure web app.

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With