Error: Access to XMLHttpRequest at 'myserviceURL' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Sample Code:
let myHeaders = new HttpHeaders();
let username: string = 'admin';
let password: string = 'admin';
myHeaders.append("Authorization", "Basic " + btoa(username + ":" + password));
myHeaders.append('Content-Type', 'application/x-www-form-urlencoded');
var data={
"username":userName,
"password":Password,
}
return this.http.post(url, data, { headers: myHeaders })
.subscribe(
res =>{
console.log(res);
},
err => {
console.log("Error occured "+err.status);
}
);
http://at the start?