My backend is set up in Node.js with Express and Sequelize. When I make a request to retrieve all my product types using Postman, everything works fine as shown in this image:
postman http request and header
However, when I try to make the same request from my Angular frontend, I encounter an error.
header Authorization is missing
This is the Angular service's HTTP request code:
getTypes(token:any):Observable<any>{
let headers = new HttpHeaders().set('Content-Type', 'application/json')
.set('Authorization', token);
console.log(headers)
return this._http.post(this.url + 'productType/getall', {headers:headers});
}
Here is the header being sent to my Postman backend:
{
authorization: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
'user-agent': 'PostmanRuntime/7.28.3',
accept: '*/*',
...
}
And here is the header being sent from my Angular frontend:
{
host: 'localhost:3002',
connection: 'keep-alive',
...
}
I'm not sure why the authorization token is not being included in the Angular request, even though the token is not null.