On my C# web api I have cors enabled i.e.
[EnableCors(origins: "*", headers: "*", methods: "*")]
and then in my angular js site I am calling post API as such
authService.login = function (credentials) {
return $http
.post(WEB_CONFIG.login, credentials)
.then(function (res) {
Session.create(res.data.Email, res.data.Roles,res.data.Username);
return res.data.user;
});
};
The angular site is making the request from localhost:9000, and the API is located at localhost
getting the error
XMLHttpRequest cannot load http://localhost/mysite/api/user/login. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9000' is therefore not allowed access.
Why am I getting this error with Cors enabled ?
methods: "*"
, but that wont help if it is added to a post-only resource. – Etse