- List item
I have a web API deployed on 'https://example.com/api/gd/alldata', when i run it directly from browser URL it shows the result. but when i call it from other Angular JS application, it is giving me below error.
Error:
Failed to load 'https://example.com/api/gd/alldata' The 'Access-Control-Allow-Origin' header contains multiple values 'http://localhost:64000, http://localhost:64000, *', but only one is allowed. Origin 'http://localhost:64000' is therefore not allowed access.
This is my new angularjs service in another application.
var promise = $http({
method: 'GET',
contentType: "application/json; charset=utf-8",
dataType: "json",
url: "https://example.com/api/gd/alldata",
//headers: headers,
headers: {
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json',
}
})
.then(function (response) {
console.log(response.data)
return response.data;
},
function (response) {
return response.data;
});
Below is my API code already deployed on some link,
i enabled cors in webapiconfig and entry on startup.cs file.
Startup.cs file
app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
webapiconfig.cs
config.EnableCors();
Can you please tell me where i am doing mistake or anything i am missing or doing wrong in my code.
