Java/Spring Boot(70)
-
Spring boot의 json 형식에 맞지 않을때, 그 데이터를 로그로 뿌려 주기
@ControllerAdvice 사용request body는 1회만 읽을 수 있기 때문에, ContentCachingRequestWrapper를 이용하여 다음 Filter에 전달GlobalExceptionHandler@Slf4j@ControllerAdvicepublic class GlobalExceptionHandler { @ExceptionHandler(HttpMessageNotReadableException.class) public ResponseEntity handleInvalidJson(HttpServletRequest request, Exception ex) { String body = extractBody(request); log.error("💥 Inval..
2025.04.07 -
JSESSIONID 다른 도메인에 전달
clientcredentials: 'include' const response = await fetch('http://localhost:8080/topics/' + name, { // REST Proxy endpoint method: 'POST', headers: { 'Content-Type': 'application/vnd.kafka.avro.v2+json' }, credentials: 'include', // ✅ This line allows cookies like JSESSIONID to be sent body: JSON.stringify(payload) ..
2025.03.14 -
has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Credentials' header in the response is '' which must be 'true' when the request's credentials mode is 'include'.
credentials: 'include'를 설정하면, 서버에서는 아래와 같이 설정되어야 함allowCredentials(true) 추가되어야 함 public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOrigins("도메인1", "도메인2") // Match your HTML server address .allowedMethods("*") .allowedHeaders("*") .allowCrede..
2025.03.14 -
Cors 에러 처리
@Configurationpublic class CorsConfig { @Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurer() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOrigins("http://127.0.0.1:5500") // Match your HTML server address .allowedMethods(..
2025.03.14 -
Spring boot org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type `java.util.ArrayList<java.util.Map<java.lang.String,java.lang.Object>>` from Object value (token `JsonToken.START_OBJECT`)
Map 형태로 데이터를 보냈는데, List 형태로 데이터를 받아서 에러 발생ClientExt.Ajax.request({ url: '/url', params: { _csrf: document.getElementById('_csrf').innerText, }, method: 'POST', jsonData: { data: data, }, success: function(response) { }, failure: function(response) { Ext.Msg.alert('Error', 'Failed to save changes.'); console.error('Server error:', response.r..
2025.01.28 -
Spring boot 파일업로드시 413 에러 발생 조치
에러413 (Request Entity Too Large)spring boot access log 확인시, 기록되는게 없음# 전체 pod 목록 확인kubectl get pods -A# Spring boot pod에 접속kubectl exec -it pod/{pod 명} -n {namespace 명} -- sh# access log 확인cd {로그 디렉토리}tail -f {로그 파일명}nginx access log 확인시, 413 에러 기록됨cd {nginx 로그 디렉토리}tail -f {access 로그 파일명}nginx ingress controller 로그 확인시 413 에러 기록됨nginx ingress controller에서 413 에러를 발생하는 것을 확인nginx의 기본 값은 1M임nginx ..
2024.12.30