I am trying to get the authentication token from the login response but the value is null and I think that only 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;
});
EDIT:
I added Access-Control-Expose-Headers to my backend response and it works.
response.setHeader("Access-Control-Expose-Headers", "Authorization");
response.addHeader("Authorization", jwtTokenProvider.generateToken(auth));
