📄 학습내용
500 error
- error 코드
- Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception
- com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input
- 참고자료
CORS 에러
- 회원가입 에러(403)
- 관련 자료
- 해결 : SecurityConfig에서 .cors(withdefault()) 메서드 주석 처리
- 이유 : securityConfig 파일에서 미리 처리를 해서 설정한 Webconfig가 동작을 안함
// 스프링 서버에 CORS 설정
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
// .allowedOrigins("*")
.allowedOrigins(
"http://localhost:8080", "http://localhost:8081",
"http://pre-project-fontend.s3-website.ap-northeast-2.amazonaws.com",
"http://ec2-13-209-69-139.ap-northeast-2.compute.amazonaws.com:8080") // 허용할 출처
.allowedMethods("GET", "POST", "HEAD", "DELETE", "PUT", "OPTIONS") // 허용할 HTTP method
.allowCredentials(true) // 쿠키 인증 요청 허용
.maxAge(10) // 원하는 시간만큼 pre-flight 리퀘스트를 캐싱
.exposedHeaders("authorization");
}
}
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
.headers().frameOptions().sameOrigin()
.and()
.csrf().disable()
// .cors(withDefaults()) // 주석처리
- AWS S3 CORS 코드
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET",
"HEAD",
"POST",
"DELETE"
],
"AllowedOrigins": [
"*"
],
"ExposeHeaders": [
"Access-Control-Allow-Origin"
]
}
]
- AWS S3 Bucket 정책
{
"Version": "2012-10-17",
"Id": "Policy1672624952532",
"Statement": [
{
"Sid": "Stmt1672624676182",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::pre-project-fontend/*"
}
]
}
주제
주제
주제
주제
🧶 발생한 문제 및 해결방법
- 문제점)
- 해결방법)
- 문제점)
- 해결방법)
- 문제점)
- 해결방법)
⭐ 공부 난이도
☆★
🌕 느낀점
'코드스테이츠 - 3회차 백엔드 부트캠프 > Pre Project' 카테고리의 다른 글
2023.01.06 금 - audit의 null 에러 (0) | 2023.01.06 |
---|---|
Pre-Project 회고록 (0) | 2023.01.02 |
2022.12.30 금 (0) | 2022.12.30 |
2022.12.29 목 (0) | 2022.12.29 |
2022.12.28 수 (0) | 2022.12.28 |