When attempting to retrieve the authentication token from the login response, I found that the value is null and suspect that only the Content-Type attribute is not null...
Login method
login(credentials: any): Observable<any> {
return this.http.post(AUTH_API + '/login', {
username: credentials.username,
password: credentials.password
}, {observe: 'response'});
}
this.authService.login(this.loginForm.value)
.subscribe((res:Response) => {
console.log(res.headers.get('Authorization'));
},
err => {
this.isLoginError = true;
this.loginErrorMessage = err.error;
});
https://i.sstatic.net/d8xDD.png
EDIT:
I made an update by including Access-Control-Expose-Headers
in my backend response and it resolved the issue.
response.setHeader("Access-Control-Expose-Headers", "Authorization");
response.addHeader("Authorization", jwtTokenProvider.generateToken(auth));