我在springboot中创建了rest,在发送有效的凭据时返回jwt访问令牌,并在httpOnly cookie中保存刷新令牌,当我向在postman中使用cookie的API发送GET请求时,它工作得很好,但是当我尝试获取rest时,返回错误表明没有cookie。
error_message:“无法读取数组长度,因为”数组“为null”
那么,如果是的话,我是否必须指定域名呢?如何在本地主机上工作(springboot正在处理localhost:8080并响应localhost:3000)。
当前如何创建cookie:
public static Cookie createRefreshCookie(String refresh_token) {
Cookie jwtRefreshCookie = new Cookie("refresh_token", refresh_token);
jwtRefreshCookie.setMaxAge(2678400);
jwtRefreshCookie.setHttpOnly(true);
jwtRefreshCookie.setPath("/");
return jwtRefreshCookie;
}发布于 2022-05-25 12:49:32
问题是我在react中的获取请求,其中包含了来自库axios的头withCredentials: true,用于获取报头credentials:"include"的实现。
https://stackoverflow.com/questions/72363772
复制相似问题