- Setting on spring boot:
private ResponseCookie makeResponseCookie(String refreshToken,Long refreshTokenValidationTime){
return ResponseCookie.from("refreshToken",refreshToken)
.httpOnly(false)// for access on javascript
.secure(true)// only on https
.path("/")
.maxAge(refreshTokenValidationTime)
.sameSite("None") // for access on different domain
.build();
}
- On React code :
const reissueToken = async () => {
const url = apiAddress + "/api/v1/auth/reissue";
const refreshToken = Cookie.get("refreshToken");
console.log("Refresh Token:", refreshToken);
const response = await fetch(url, {
method: "POST",
headers: {
"accessToken": token,
"refreshToken": refreshToken
},
credentials: 'include',
});
If i test on localhost, We can find Cookie on Chrome application tab!
enter image description here
But i can’t access cookie by above code! with refresh token is undefined
enter image description here
and it works on deployed frontend webpage!
I think it’s a matter of domain( frontend , backend on same ec2 using reverse proxing & same domain)
But Why????(localhost & spring boot server also applied https)
I set sameSite None on Spring boot and i expected it works!
- What is my problem
- How can i Test cookie on localhost(frontend)
i tried almost eveything lol