suminiee / 2024_Baseball_diary

0 stars 0 forks source link

응원 팀 변경 템플릿을 구현하고 테스트 할 때 #21

Open suminiee opened 1 month ago

suminiee commented 1 month ago

변경하기 버튼을 누르면

오류내용

“status”:405, “error”:”Method not allowed”, “trace”:”org.springframework.web.HttpRequestMethodNotSupportedException: Request method ‘PUT’ is not supported n tat org.springframework.web.servlet.mvc.method...

이런내용의 오류가 발생해서 찾아봤는데 PUT을 제대로 사용하지 않았거나 요청 주소가 잘못되었거나, spring security에서 CSRF때문에 보안상 막아둬서 안될 수 있다고 했다.

SecurityConfig - SecurityFilterChain


http
.csrf(AbstractHttpConfigurer::disable)

이미 이렇게 설정해둬서 csrf 문제는 아닌것같아서 찾아보니 ajax 요청을 할 때 url부분에 실수를 했다

>changeMyTeam.mustache

$.ajax({ url: '/api/changeMyTeam', type: 'PUT',



저 부분에서 url에 '/api'를 안붙이고 요청을 보내서 주소를 못찾는거였다..! 엔드포인트의 컨트롤러 요청주소를 잘 확인하고 써야겠다는 생각을 하게됐다,,허허 이거 찾느라 당황스러웠다