Skip to content

Commit

Permalink
Merge pull request #207 from APPS-sookmyung/dev
Browse files Browse the repository at this point in the history
[Fix] cookie 설정
  • Loading branch information
ajung7038 authored Dec 26, 2024
2 parents 3c21768 + c41b18c commit b7fa483
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/main/java/WELLET/welletServer/config/CorsMvcConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ public class CorsMvcConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry corsRegistry) {

corsRegistry.addMapping("/**")
.exposedHeaders("Set-Cookie")
.allowedOrigins("http://localhost:8000", frontendUrl)
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") // 허용할 HTTP method
.allowCredentials(true); // 쿠키 인증 요청 허용
// corsRegistry.addMapping("/**")
// .exposedHeaders("Set-Cookie")
// .allowedOrigins("http://localhost:8000", frontendUrl)
// .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") // 허용할 HTTP method
// .allowCredentials(true); // 쿠키 인증 요청 허용
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ public String callback(@RequestParam("code") String code, HttpServletResponse re
// 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("/");
response.addCookie(jwtCookie);
// Cookie jwtCookie = new Cookie("jwtToken", jwtToken);
// jwtCookie.setHttpOnly(true);
// jwtCookie.setSecure(true); // HTTPS에서만 전송
// jwtCookie.setMaxAge(60 * 60 * 24); // 쿠키 유효 시간 설정
// jwtCookie.setPath("/");
// response.addCookie(jwtCookie);

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

Expand All @@ -123,7 +123,7 @@ public String callback(@RequestParam("code") String code, HttpServletResponse re


// jwtCookie.setDomain(frontendUrl);
response.addCookie(jwtCookie);
// response.addCookie(jwtCookie);

// ResponseCookie jwtCookie = ResponseCookie.from("jwtToken", jwtToken)
// .httpOnly(true)
Expand Down

0 comments on commit b7fa483

Please sign in to comment.