我在两个不同的服务器上部署了带有reactjs(frontEnd)和springboot(后端)的web应用程序。
它们都是http服务器,而不是HTTPS。
我搜索了所有与此相关的堆叠溢出问题,但似乎都没有效果。
我是使用spring-session依赖项或Spring-security依赖项的而不是。
为了维护用户会话,我只是让我的beans @SessionScoped,如果一切都在相同的服务器上,但在不同的服务器上,它就可以正常工作。
浏览器给出了这个错误,因为不能设置samesite=none,在http上,这个https是必需的。
那么解决这个问题的方法是什么呢?因为我现在不能让我的服务器成为https。
发布于 2021-09-29 14:48:12
我使用ResponseCookie解决了这个问题。见下文:
final ResponseCookie responseCookie = ResponseCookie
.from("test", "test")
.secure(true)
.httpOnly(true)
.path("/")
.maxAge(12345)
.sameSite("None")
.build();
response.addHeader(HttpHeaders.SET_COOKIE, responseCookie.toString());Cookie名称: test和Value: test。
需要设置安全的true才能使用sameSite(“无”)。
这应该能救你的琦琦
https://stackoverflow.com/questions/67850607
复制相似问题