I have the following angularjs code:
this.createAccount = function (payload) {
var parameters = {
grant_type: 'password',
client_id: clientId,
client_secret: clientSecret,
email: payload.Email,
password: payload.Password,
scope: 'myApi offline_access openid'
}
return $http({
method: "POST",
url: $sce.trustAsResourceUrl(identityApiURL + '/account/register'),
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'application/json'
},
data: 'grant_type=' + parameters.grant_type + '&client_id=' + parameters.client_id + '&client_secret=' + parameters.client_secret + '&email=' + encodeURIComponent(parameters.email) + '&password=' + parameters.password + '&scope=' + parameters.scope
}).error(function (response) {
$log.error('Something went wrong when creating your account', response);
});
}
When trying to run it I keep on getting the following error in the console:
Failed to load https://........account/register: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://localhost:3000' is therefore not allowed access.
I can see that a config object is being created with my params but data is NULL. Also on the Network I see OPTIONS but no POST method is triggered...
What is wrong?
Thanks in advance!