How to get response from 2nd azure static web app when called from the 1st static web app?

84 views Asked by At

Currently I am trying to capture the user's credentials from login to 1st app and trying to send it while calling 2nd static web app.

getUserInfo()
.then(async (clientPrincipal) =>  {
console.log(clientPrincipal);
const response = await fetch(url_of_2nd_azure_static_web_app, {
headers: {
'X-MS-CLIENT-PRINCIPAL-NAME': clientPrincipal.userDetails,
'X-MS-CLIENT-PRINCIPAL-ID': clientPrincipal.userId,
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type, Authorization, X-Requested-With'
}
});
}, []);

I am not sure if it is even possible ? This is image of the error that I am facing

enter image description here

I have already tried adding global headers to my staticwebapp.config.json & I am still getting CORS Error.

'globalHeaders': {
    "Access-Control-Allow-Origin": "*",
    "Access-Control-Allow-Methods": "GET, OPTIONS"
},
0

There are 0 answers