Here is the function that makes a POST call to the server:
submitData(credential){
credential = JSON.stringify(credential);
return this._http.post("http://localhost:8080/login",credential,{observe: 'response'});
}
In this section, I am logging the data in the console:
this.jwtService.submitData(data)
.subscribe((data)=>{
console.log(data);
})
Below is the response I receive in the console:
HttpResponse {headers: HttpHeaders, status: 200, statusText: "OK", url: "http://localhost:8080/login", ok: true, …}
headers: HttpHeaders
normalizedNames: Map(0)
[[Entries]]
No properties
size: 0
When checking my browser's Network tab, I can see the Authorization header with its value:
Request URL: http://localhost:8080/login
Request Method: POST
Status Code: 200
Remote Address: [::1]:8080
Referrer Policy: no-referrer-when-downgrade
Response Headers:
Access-Control-Allow-Origin: http://localhost:4200
Access-Control-Expose-Headers: Authorization
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJuYWNodSIsImV4cCI6MTU4NDg2MTYxOH0.Bh46Bv4YWou5kzNp2ib_14Xnu9Ob7G41QqY4_t6UzxdJiq-CHX1yk7BWBmHlOXygMuS7YNVNu0HkhnREoY69iQ
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Connection: keep-alive
Content-Length: 0
Date: Sun, 22 Mar 2020 06:20:18 GMT
Expires: 0
Keep-Alive: timeout=60
Pragma: no-cache
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
I also replicated the same response using Postman application.
I am currently seeking a workaround for this issue.