Spring Boot从Angular获取jwt授权标头为空

时间:2019-12-13 09:18:56

标签: angular spring-boot jwt

我在JWT中使用spring boot。创建API 客户端角度调用API。

getAllPost(): Observable<any> {
const httpOptions = {
  headers: new HttpHeaders({
    'Content-Type': 'application/json',
    'H-auth': localStorage.getItem('H-Token')
  })
};
return this.http.get(API.SERVER + '/posts.find', httpOptions);

}

localStorage.getItem( 'H-令牌')= 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJldm5pdFxcYWFhIiwiYXV0aCI6W3siYXV0aG9yaXR5IjoiUk9MRV9BRE1JTiJ9XSwiaWF0IjoxNTc2MjE5NTI5LCJleHAiOjE1NzYzMDU5Mjl9.NFAUYwcHrgklqBh-KVsY9K4E8GXAjV8X090SwK59Lqk'

运行角度应用 调用API字符串bearerToken = req.getHeader(“ h-auth”); -> ==空;

enter image description here

我通过APP呼叫“高级REST客户端-Google Chrome”

enter image description here

enter image description here

帮帮我。 谢谢

0 个答案:

没有答案