Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No 'Access-Control-Allow-Origin' header is present on the requested resource for azure web app

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.*

like image 360
Kalum Umesh Avatar asked Oct 24 '25 14:10

Kalum Umesh


1 Answers

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.

enter image description here

like image 108
Kalum Umesh Avatar answered Oct 27 '25 05:10

Kalum Umesh