I have a website, backend is in spring, frontend is in React. I save a cookie on backend using
Cookie cookie = new Cookie("userId", testDTO.getId());
userCookie.setPath("/");
response.addCookie(userCookie);
But when react posts request on the controller, my browser doesnt get that cookie. Storage in firefox is just empty.
Frontend code:
const requestOptions = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
name: username,
stayLogged: false
})
};
fetch('http://localhost:8080/health-check/post',requestOptions)
.then(response => response.json())
.then(data =>{console.log(data);})