Skip to content

Commit

Permalink
bug : react에 코키를 못받아서 domain 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
KMGeon committed Nov 21, 2023
1 parent 2396b41 commit 2131438
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseCookie;
import org.springframework.security.core.Authentication;
import org.springframework.security.oauth2.core.user.OAuth2User;
Expand Down Expand Up @@ -71,17 +72,19 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
String redirectUri = FRONT_BASE_URL + "oauth2/login";


ResponseCookie cookie = ResponseCookie.from("accessToken", access)
ResponseCookie accResponseCookie = ResponseCookie.from("accessToken", access)
.path("/")
.secure(true)
.domain(".cstudying.site")
.maxAge(1800)
.sameSite("None")
.httpOnly(false)
.build();

ResponseCookie cookie2 = ResponseCookie.from("refreshToken", refresh)
ResponseCookie responseCookie = ResponseCookie.from("refreshToken", refresh)
.path("/")
.secure(true)
.domain(".cstudying.site")
.maxAge(604800)
.sameSite("None")
.httpOnly(false)
Expand All @@ -92,8 +95,10 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
log.info("refresh token : {}", refresh);
log.info("redirect url : {}", redirectUri);

response.setHeader("Set-Cookie", cookie.toString());
response.addHeader("Set-Cookie", cookie2.toString());
// response.setHeader("Set-Cookie", cookie.toString());
// response.addHeader("Set-Cookie", cookie2.toString());
response.setHeader(HttpHeaders.SET_COOKIE, accResponseCookie.toString());
response.addHeader(HttpHeaders.SET_COOKIE, responseCookie.toString());

String targetUrl = UriComponentsBuilder.fromUriString(redirectUri)
.build().toUriString();
Expand Down

0 comments on commit 2131438

Please sign in to comment.