I am using Angular 5 in my ionic app. I am trying to call a endpoint from my code
ngOnInit(): void {
//Called after the constructor, initializing input properties, and the first call to ngOnChanges.
//Add 'implements OnInit' to the class.
this.httpClient.get('https://abc-66b76.cloudfunctions.net/getBillNo', {
headers: {
'Access-Control-Allow-Origin': '*'
}
}).subscribe(data => {
console.log('firebase bill No: ', data);
this.bill.billNo = data.billNo;
})
}
When my page loads the above code is called and in chrome browser console i get the below error:
Failed to load https://abc-66b76.cloudfunctions.net/getBillNo: 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:8100' is therefore not allowed access.
However if i check my network tab in my chrome browser i can see that it has hit the server and has got the response.
Can anyone help me resolve this.
My Backend is firebase functions.

headers: { 'Access-Control-Allow-Origin': '*'}in the request header? that's not how cors works, the server needs to sendAccess-Control-Allow-Origin: *in its responseHowever if i check my network tab in my chrome browser i can see that it has hit the server and has got the response.- yes, because the console can see more than your code - it's a useful debugging tool, not a mirror of what your code can see