inSessionOtpCode==null
改了@CrossOrigin(allowCredentials?=?"true",allowedHeaders?=?"*")和xhrFields:{withCredentials:true},
這兩個地方還是null,springboot版本是2.0改了@CrossOrigin(allowCredentials?=?"true",allowedHeaders?=?"*")和xhrFields:{withCredentials:true},
這兩個地方還是null,springboot版本是2.0舉報
2022-04-18
前端代碼要加上這倆:
xhrFields:?{withCredentials:?true}, crossDomain:?true,后端如果啟動不了,就這么寫
我的跨域問題就這么解決的
2022-04-18
前端代碼要加上這倆:
xhrFields:?{withCredentials:?true},后端如果啟動不了,就這么寫
我的跨域問題就這么解決的
2022-04-12
springboot2.6.x版本可以如下設(shè)置,在application.properties中設(shè)置
2022-04-01
他媽的搞了好幾天終于解決這個問題了,帖子里在response里設(shè)置header里set-cookie的不會生效試過了,響應(yīng)頭里會有兩個set-cookie不知道為什么,可能是chorme版本問題。視頻spring里使用的是2.0.5.RELEASE版本 這個版本找不到sameSite屬性,我將springboot升級到然后設(shè)置一個config類,在config類中設(shè)置如下的配置 @Bean public?CookieSerializer?httpSessionIdResolver(){ ????DefaultCookieSerializer?cookieSerializer?=?new?DefaultCookieSerializer(); ????//?源碼默認為Lax ????//?private?String?sameSite?=?"Lax"; ????cookieSerializer.setSameSite("None"); ????cookieSerializer.setUseSecureCookie(true); ????return?cookieSerializer; } 親測有用,被這個bug折磨死了?。。。?!2022-03-14
2021-09-08
這個是根據(jù)樓上回答寫的,主要的原因是springboot里面多加了samesite這個設(shè)置,需要降低其等級。具體原理,可以自己百度一下這個參數(shù)。
2021-09-06
在類中加入
之后,在接口中設(shè)置samesite=None, httponly,secure等屬性
ResponseCookie?cookie?=?ResponseCookie.from("JSESSIONID",?httpServletRequest.getSession().getId()?)?//?key?&?value ????????.httpOnly(true)???????//?禁止js讀取 ????????.secure(true)?????//?在http下也傳輸 ????????.domain("localhost")//?域名 ????????.path("/")???????//?path ????????.maxAge(3600)??//?1個小時候過期 ????????.sameSite("None")??//?大多數(shù)情況也是不發(fā)送第三方?Cookie,但是導(dǎo)航到目標網(wǎng)址的?Get?請求除外 ????????.build() ????????; httpServletResponse.setHeader(HttpHeaders.SET_COOKIE,?cookie.toString());2021-08-11
我也有這個問題,不知道怎么解決,求教
2021-08-11
@CrossOrigin(origins?=?{"*"},?allowCredentials?=?"true")試試這個,我用這個可以