diff --git a/src/main/java/com/softeer/backend/fo_domain/share/controller/ShareController.java b/src/main/java/com/softeer/backend/fo_domain/share/controller/ShareController.java index 88b27ec9..b5397e9c 100644 --- a/src/main/java/com/softeer/backend/fo_domain/share/controller/ShareController.java +++ b/src/main/java/com/softeer/backend/fo_domain/share/controller/ShareController.java @@ -5,7 +5,9 @@ import com.softeer.backend.global.annotation.AuthInfo; import com.softeer.backend.global.common.response.ResponseDto; import io.swagger.v3.oas.annotations.Parameter; +import jakarta.servlet.http.Cookie; import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpHeaders; @@ -26,10 +28,13 @@ public ResponseDto getShortenShareUrl(@Parameter(hidden } @GetMapping("/share/{shareUrl}") - public ResponseEntity redirectWithShareUrl(@PathVariable String shareUrl, HttpServletRequest request) { + public ResponseEntity redirectWithShareUrl(@PathVariable String shareUrl, HttpServletRequest request, HttpServletResponse response) { // session을 이용해 공유 url 저장 - HttpSession session = request.getSession(); - session.setAttribute("shareUrl", shareUrl); + Cookie shareCodeCookie = new Cookie("shareCode", shareUrl); + shareCodeCookie.setPath("/"); + shareCodeCookie.setHttpOnly(false); // HttpOnly 속성을 비활성화 + shareCodeCookie.setDomain("softeer.site"); // 도메인 설정. 이렇게 해서 softeer.site 포함 하위 모든 도메인에서 해당 쿠키 사용 가능 + response.addCookie(shareCodeCookie); // 헤더를 이용해 redirect HttpHeaders headers = new HttpHeaders(); diff --git a/src/main/java/com/softeer/backend/global/staticresources/constant/StaticText.java b/src/main/java/com/softeer/backend/global/staticresources/constant/StaticText.java index 2838b0fc..fc1fb6d8 100644 --- a/src/main/java/com/softeer/backend/global/staticresources/constant/StaticText.java +++ b/src/main/java/com/softeer/backend/global/staticresources/constant/StaticText.java @@ -97,7 +97,7 @@ public enum StaticText { "이벤트 당첨 이후 개인정보 제공을 거부하거나 개별 안내를 거부하는 경우, 당첨이 취소될 수 있습니다."), // 공유 url - BASE_URL("https://softeer.site/share/"), + BASE_URL("https://softeer.shop/share/"), NON_USER_SHARE_URL("https://softeer.site"), // 선착순