【发布时间】:2020-08-31 06:28:01
【问题描述】:
我有一个网站,后端是 spring,前端是 React。我使用
在后端保存了一个cookieCookie cookie = new Cookie("userId", testDTO.getId());
userCookie.setPath("/");
response.addCookie(userCookie);
但是当 react 在控制器上发布请求时,我的浏览器没有得到那个 cookie。 Firefox 中的存储空间是空的。
前端代码:
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);})
【问题讨论】:
标签: java reactjs spring-boot cookies