From d0c49bb2a464d7994677910d6b194a7da08b7428 Mon Sep 17 00:00:00 2001 From: ajeong Date: Thu, 26 Dec 2024 23:43:35 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20cookie=20=EC=84=A4=EC=A0=95=20#149?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WELLET/welletServer/config/CorsMvcConfig.java | 10 +++++----- .../controller/KakaoLoginController.java | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/WELLET/welletServer/config/CorsMvcConfig.java b/src/main/java/WELLET/welletServer/config/CorsMvcConfig.java index ab438fc..2e19d9b 100644 --- a/src/main/java/WELLET/welletServer/config/CorsMvcConfig.java +++ b/src/main/java/WELLET/welletServer/config/CorsMvcConfig.java @@ -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); // 쿠키 인증 요청 허용 } } diff --git a/src/main/java/WELLET/welletServer/kakaologin/controller/KakaoLoginController.java b/src/main/java/WELLET/welletServer/kakaologin/controller/KakaoLoginController.java index 354f6c2..fb06a42 100644 --- a/src/main/java/WELLET/welletServer/kakaologin/controller/KakaoLoginController.java +++ b/src/main/java/WELLET/welletServer/kakaologin/controller/KakaoLoginController.java @@ -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"); @@ -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)