I've created rest API in springboot that upon sending valid credentials returns jwt access token and saves refresh token in httpOnly cookie, when I send GET request to the API that uses cookie in postman it works just fine but when I try to fetch in react API returns error that indicates that there is no cookies
error_message: "Cannot read the array length because "array" is null"
So do I have to specify domain name If yes how do I do it while working on localhost (springboot is working on localhost:8080
and react localhost:3000
).
How I currently create 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;
}
问题是由我的 fetch 请求引起的,其中包含 header withCredentials: true
来自库 axios insead 的 fetch implementation of header credentials:"include"
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.