Reputation: 13
I am having an issue with my jwt authentication.
I am trying to get a list of templates from my rest api, but when I try to access the header 'Authorization', the value is null.
Here is my code:
loadTemplates(): Observable<Template[]> {
const headers = new Headers({'Authorization': this.authService.getPrefix() + this.authService.getLocalToken()})
return this.httpService.post(this.baseURL + 'api/templates/short', {headers: headers})
.map((res: Response) => res.json())
.catch((error: any) => Observable.throw(error.json().error));
}
The Prefix and also the Token is set, I can see them when I log them in the console.
The probem is, when I look in the developer console in Chrome, I can see the
Access-Control-Request-Headers: authorization
But it is null in the backend. (Tried to log the value of the header 'Authorization')
When I try to access the backend via Postman it does work. With the same prefix + token.
Upvotes: 1
Views: 421
Reputation: 2398
My guess is, that you forgot to handle so called 'preflight' request on the server side. Try to add something like this this filter.
Upvotes: 2