diff --git a/src/main/java/workplate/workplateserver/auth/domain/entity/MemberDetail.java b/src/main/java/workplate/workplateserver/auth/domain/entity/MemberDetail.java index 22ed7fa..215ecda 100644 --- a/src/main/java/workplate/workplateserver/auth/domain/entity/MemberDetail.java +++ b/src/main/java/workplate/workplateserver/auth/domain/entity/MemberDetail.java @@ -62,8 +62,9 @@ public static MemberDetail toEntity(Member member, MemberDetailRequest request) .age(request.getAge()) .location(request.getLocation()) .mainPreference(request.getMainPreference()) - .subExperience(request.getSubExperience()) .subPreference(request.getSubPreference()) + .mainExperience(request.getMainExperience()) + .subExperience(request.getSubExperience()) .physicalStatus(request.getPhysicalStatus()) .build(); } diff --git a/src/main/java/workplate/workplateserver/common/ControllerAdvice.java b/src/main/java/workplate/workplateserver/common/ControllerAdvice.java index 309aff9..c1fdf21 100644 --- a/src/main/java/workplate/workplateserver/common/ControllerAdvice.java +++ b/src/main/java/workplate/workplateserver/common/ControllerAdvice.java @@ -6,6 +6,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; +import jakarta.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; /** @@ -18,15 +19,24 @@ @RestControllerAdvice public class ControllerAdvice { + private void addCorsHeaders(HttpServletResponse response) { + response.setHeader("Access-Control-Allow-Origin", "*"); + response.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS"); + response.setHeader("Access-Control-Allow-Headers", "Authorization, Content-Type"); + response.setHeader("Access-Control-Allow-Credentials", "true"); + } + @ExceptionHandler(Exception.class) - public ResponseEntity> common(Exception e) { + public ResponseEntity> common(Exception e, HttpServletResponse response) { + addCorsHeaders(response); // CORS 헤더 추가 log.error("[밥상일터]: 예상치 못한 예외가 발생하였습니다. 예외내용 = {}", e.getMessage()); return ResponseEntity.status(HttpStatus.BAD_REQUEST) .body(ApiResponse.failure("관리자에게 문의해주세요.")); } @ExceptionHandler({IllegalArgumentException.class, AccessDeniedException.class}) - public ResponseEntity> illegalArgument(Exception e) { + public ResponseEntity> illegalArgument(Exception e, HttpServletResponse response) { + addCorsHeaders(response); // CORS 헤더 추가 return ResponseEntity.status(HttpStatus.BAD_REQUEST) .body(ApiResponse.failure(e.getMessage())); }