I am using Azure APIM , my APIs are hosted on Azure app service coded by .net core . I have configed my apis behind APIM . However , when I tried to call my APIs , I got this issue :
Access to fetch at '' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: 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.
This is the js code that I call my API :
var url='<the url of my api in APIM>';
fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Seckey":"xxxxxx"
},
body: '<some json content>'
}).then(function(res) {
console.log("Response succeeded?", JSON.stringify(res.status));
console.log(JSON.stringify(res));
}).catch(function(e) {
console.log("fetch fail", JSON.stringify(e));
});
I know this is a CORS issue , and I have configed CORS policy in APIM based on this doc : https://docs.microsoft.com/en-us/azure/api-management/api-management-cross-domain-policies#CORS
However, it did not solve this issue . So did I miss something ?
Thanks in advance.