I am trying to hit an https based API, which is successfully working in POSTMAN and other REST client, but not in my AngularJS app.
Following is the code -
var req = {
method: 'POST',
url: 'https://agXXXXX.com/api/contact/',
headers: {
'Content-Type': undefined
},
data: user,
withCredentials: true
};
$http(req)
.then(function(data){
console.log("--Data--");
console.log(data);
})
After following few stack CORS related article, I also included this in .config()
, but no luck -
$httpProvider.defaults.useXDomain = true;
$httpProvider.defaults.headers.common = {Accept: "application/json, text/plain, */*"};
$httpProvider.defaults.headers.post = {"Content-Type": "application/json;charset=utf-8"};
Following is the error I am facing -
Let me know what I am doing wrong, or missing here.
http
vs.https
issue unless the origin domain is the same, and the page attempting the access is nothttp
but the service is.