Reputation: 713
I am trying to read a JSESSIONID cookie (Set-Cookie) from the HTTP response that I get from the server.
The network tab shows me response header :
when I try to get the response I dont see it.
return this.http
.get(environment.domain + '/rest/getSessionConfirmationNumber',
{observe: 'response'})
.retryWhen(this.config.handleRetry)
.catch(this.config.handleError)
.map(response => {
console.log('getSession success')
console.log('The cookie jSession ',
this.cookieService.get('JSESSIONID'))
}
Also used ngx-cookie-service package (this only gives me cookie present in the application tab in browser)
also tried withCredential=true in the get request. throws some sort of CORS error (the plugin is on).
The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'http://localhost:4200' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute
EDIT1: Tried update xml as per CORS: Cannot use wildcard in Access-Control-Allow-Origin when credentials flag is true
<init-param>
<param-name>cors.allowed.origins</param-name>
<param-value>http://localhost:4200</param-value>
</init-param>
still doesnt work.
Upvotes: 1
Views: 4322
Reputation: 496
you have a typo in your code,
you have
this.cookieService.get('JSESSOINID'))
should be
this.cookieService.get('JSESSIONID'))
Upvotes: 0