Skip to content

Commit

Permalink
Merge pull request #167 from APPS-sookmyung/dev
Browse files Browse the repository at this point in the history
[Fix] 쿠키 수정
  • Loading branch information
ajung7038 authored Dec 24, 2024
2 parents 516a5d7 + 3d240b4 commit 79c7813
Showing 1 changed file with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,32 @@ public String callback(@RequestParam("code") String code, HttpServletResponse re
// 4. JWT 생성
String jwtToken = jwtService.generateToken(member); // 생성된 또는 업데이트된 사용자로 JWT 생성
//
// // 5. 쿠키에 JWT 저장
Cookie jwtCookie = new Cookie("jwtToken", jwtToken);
jwtCookie.setHttpOnly(true); // JavaScript로 쿠키에 접근 불가
jwtCookie.setSecure(true); // HTTPS에서만 전송
jwtCookie.setMaxAge(60 * 60 * 24); // 쿠키 유효 시간 설정
jwtCookie.setPath("/"); // 쿠키를 모든 경로에 적용
//// // 5. 쿠키에 JWT 저장
// Cookie jwtCookie = new Cookie("jwtToken", jwtToken);
// jwtCookie.setHttpOnly(true); // JavaScript로 쿠키에 접근 불가
// jwtCookie.setSecure(false); // HTTPS에서만 전송
// jwtCookie.setMaxAge(60 * 60 * 24); // 쿠키 유효 시간 설정
// jwtCookie.setPath("/"); // 쿠키를 모든 경로에 적용
//
// jwtCookie.setDomain("wellet.netlify.app");
// response.addCookie(jwtCookie);

ResponseCookie jwtCookie = ResponseCookie.from("jwtToken", jwtToken)
.httpOnly(true)
.secure(true)
.path("/")
.sameSite("None")
.maxAge(60 * 60 * 24)
.build();
response.addHeader(HttpHeaders.SET_COOKIE, jwtCookie.toString());

jwtCookie.setDomain("wellet.netlify.app");
response.addCookie(jwtCookie);

// 리다이렉트 URL 설정
String redirectUrl = "https://wellet.netlify.app"; // 원하는 프론트엔드 URL
// String redirectUrl = "http://localhost:8000"; // 원하는 프론트엔드 URL
response.sendRedirect(redirectUrl);


return "로그인 성공";

} catch (Exception e) {
Expand Down

0 comments on commit 79c7813

Please sign in to comment.