JWT在响应授权标头中不可用,但在“网络”选项卡中存在

时间:2018-12-16 21:37:37

标签: reactjs cors

我有一个Spring Boot应用程序作为后端API,有一个React应用程序作为前端。 CORS在Spring Boot中启用,我使用axios将请求发送到Spring Boot API。 当调用'/ login'时,Spring Boot安全性启动并生成一个JWT 令牌,作为授权标头传递回ReactJS。的 问题是此标头未出现在 React应用then处理块。它确实在开发人员中正确显示 工具网络标签。下面是相关代码:

axios.post("http://localhost:8080/login", LoginRequest)
  .then(response => {console.log("RRR ", response)});

控制台输出如下:

{data: "", status: 200, statusText: "", headers: {…}, config: {…}, …}
config:
adapter: ƒ xhrAdapter(config)
data: "{"username":"test@test.com","password":"test$2"}"
headers:
Accept: "application/json, text/plain, */*"
Content-Type: "application/json;charset=utf-8"
__proto__: Object
maxContentLength: -1
method: "post"
timeout: 0
transformRequest: {0: ƒ}
transformResponse: {0: ƒ}
url: "http://localhost:8080/login"
validateStatus: ƒ validateStatus(status)
xsrfCookieName: "XSRF-TOKEN"
xsrfHeaderName: "X-XSRF-TOKEN"
__proto__: Object
data: ""
headers: {pragma: "no-cache", cache-control: "no-cache, no-store, max-age=0, must-revalidate", expires: "0"}
request: XMLHttpRequest {onreadystatechange: ƒ, readyState: 4, timeout: 0, withCredentials: false, upload: XMLHttpRequestUpload, …}
status: 200
statusText: ""

我想念什么?

0 个答案:

没有答案