Mainly needed when using Net Core API endpoint with windows authentication. In order to authenticate correctly couple of things needs to be done
Before setting up anything in IIS 10, CORS needs to be enabled. To do so (Additionally CORS Extension might need to be installed)
<system.webServer>
</system.webServer>
$(document).ready(function () {
var settings = {
"url": "[ENDPOINT]",
"method": "GET",
"crossDomain": true, // THIS LINE TO BE INLCUDED
"xhrFields": {
withCredentials: true // THIS LINE TO BE INLCUDED
},
};
$.ajax(settings)
.done(function (response) {
console.log(response)
})
});
// Or use it as function helper to make calls easier and DRY
function APIHelper(url) {
var settings = {
"url": url,
"method": "GET",
"crossDomain": true,
"xhrFields": {
withCredentials: true
},
};
return settings;
}