I have created .NET Core WebAPI and in each request I add custom header into response.
context.Response.Headers.Add("X-Access-Token", newToken);
I also enbaled cors in server side:
app.UseCors(config => config.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin());
Every request in Augular2 side I am filtering and trying to get the "X-Access-Token" header but that returns null.
getVehiclesReport(dateFrom: Date, dateTo: Date, loaderName): Observable<IVehiclesReport> {
return this.http.get(this.baseUrl + "report/vehicles/" + this.getQueryDate(dateFrom) + "/" + this.getQueryDate(dateTo), this.jsonHeadersAuth)
.map((response: Response) => this.mapResponse(response, response =><IVehiclesReport>response.json()))
.catch(this.handleError)
.finally(() => this.ajaxService.push(loaderName));
}
protected mapResponse<TResult>(response: Response, func : Func<Response, TResult>): TResult {
let token = response.headers.get("X-Access-Token");
//returns null
if(token && token != null && token != ''){
this.localStorageService.setJwtToken(token);
}
return func(response);
}
However I can see my X-Access-Token in Developer Options / Network / Response Headers.
Did somone faced that issue?