diff --git a/src/main/java/workplate/workplateserver/common/ControllerAdvice.java b/src/main/java/workplate/workplateserver/common/ControllerAdvice.java index c1fdf21..dff9299 100644 --- a/src/main/java/workplate/workplateserver/common/ControllerAdvice.java +++ b/src/main/java/workplate/workplateserver/common/ControllerAdvice.java @@ -18,26 +18,16 @@ @Slf4j @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, HttpServletResponse response) { - addCorsHeaders(response); // CORS 헤더 추가 log.error("[밥상일터]: 예상치 못한 예외가 발생하였습니다. 예외내용 = {}", e.getMessage()); - return ResponseEntity.status(HttpStatus.BAD_REQUEST) + return ResponseEntity.status(HttpStatus.OK) .body(ApiResponse.failure("관리자에게 문의해주세요.")); } @ExceptionHandler({IllegalArgumentException.class, AccessDeniedException.class}) public ResponseEntity> illegalArgument(Exception e, HttpServletResponse response) { - addCorsHeaders(response); // CORS 헤더 추가 - return ResponseEntity.status(HttpStatus.BAD_REQUEST) + return ResponseEntity.status(HttpStatus.OK) .body(ApiResponse.failure(e.getMessage())); } diff --git a/src/main/java/workplate/workplateserver/config/SecurityConfig.java b/src/main/java/workplate/workplateserver/config/SecurityConfig.java index dc081a6..31383a4 100644 --- a/src/main/java/workplate/workplateserver/config/SecurityConfig.java +++ b/src/main/java/workplate/workplateserver/config/SecurityConfig.java @@ -1,13 +1,11 @@ package workplate.workplateserver.config; -import org.springframework.boot.autoconfigure.security.servlet.PathRequest; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; -import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer; import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;