I am trying to set headers when making a get request from Angular, but it's not working. The route is correct, I've tested it with a REST client (Insomnia) and everything is ok.
Here's my Angular code:
const options = {
headers: {
Authorization: 'XXXXXXXXXXXXX'
}
};
this.http.get(this.endpoint, options).subscribe((data) => {
console.log(data);
}, (error) => {
console.log(error);
});
I've checked endpoint
and options
and I cannot see any problems. I always get error code 401 and the following message:
Access to XMLHttpRequest at XXXXXX from origin YYYYYYYYY has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
I also correctly enabled CORS on API Gateway, and when I remove the Authorizer from the interface it's working correctly
Here's what I have in my request: