Skip to content

Commit

Permalink
Merge pull request #204 from APPS-sookmyung/nginx_feat/#149
Browse files Browse the repository at this point in the history
[Fix] 쿠키 헤더 설정
  • Loading branch information
ajung7038 authored Dec 26, 2024
2 parents 581995e + c224481 commit 185acb9
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,21 @@ public String callback(@RequestParam("code") String code, HttpServletResponse re
String jwtToken = jwtService.generateToken(member); // 생성된 또는 업데이트된 사용자로 JWT 생성
//
//// // 5. 쿠키에 JWT 저장
Cookie jwtCookie = new Cookie("Set-Cookie", jwtToken);
jwtCookie.setHttpOnly(true); // JavaScript로 쿠키에 접근 불가
jwtCookie.setSecure(true); // HTTPS에서만 전송
// Cookie jwtCookie = new Cookie("Set-Cookie", jwtToken);
// jwtCookie.setHttpOnly(true); // JavaScript로 쿠키에 접근 불가
// jwtCookie.setSecure(true); // HTTPS에서만 전송
// jwtCookie.setMaxAge(60 * 60 * 24); // 쿠키 유효 시간 설정
// jwtCookie.setPath("/"); // 쿠키를 모든 경로에 적용
// jwtCookie.setDomain("wellet");

Cookie jwtCookie = new Cookie("jwtToken", jwtToken);
jwtCookie.setHttpOnly(true);
jwtCookie.setSecure(true); // HTTPS에서만 전송
jwtCookie.setMaxAge(60 * 60 * 24); // 쿠키 유효 시간 설정
jwtCookie.setPath("/"); // 쿠키를 모든 경로에 적용
jwtCookie.setDomain("wellet");
jwtCookie.setPath("/");
response.addCookie(jwtCookie);

response.addHeader("Set-Cookie", "jwtToken=" + jwtToken + "; Path=/; HttpOnly; Secure; Max-Age=" + (60 * 60 * 24) + "; SameSite=None");

// response.setHeader("Set-Cookie","token=" + jwtToken +. ;Path=/; Domain=localhost; HttpOnly; Max-Age=604800; SameSite=None; Secure;");

Expand Down

0 comments on commit 185acb9

Please sign in to comment.