cors 에러 문제가 자꾸 나서 원인을 파악하려 했지만 찾기가 힘들었다.
이미 하라는 것은 다했기 때문에 뭐가 문제인지 몰랐다. 하지만 원인은 너무도 쉬운 것이었다.
원래 쉬운 것을 찾는게 더 어려운 것 같다....
app:
cors:
allowedOrigins: http://localhost:8080, http://localhost:8081, http://localhost:3000
이런식으로 허용해주고 있었는데
private List<String> parseAllowedOrigins() {
return Arrays.asList(allowedOrigins.split(","));
}
- 여기가 문제였다. 콤마하고 띄워쓰기가 있어서 제대로 적용이 되지 않았던 것이다...ㅠㅠㅠ
private List<String> parseAllowedOrigins() {
return Arrays.stream(allowedOrigins.split(","))
.map(String::trim)
.collect(Collectors.toList());
}
- 그래서 trim으로 띄워쓰기를 제거해주고나니 해결이 되었다. 정말 에러의 원인을 찾는건 너무나도 어렵다..
'개발이 좋아서 > Troubleshooting이 좋아서' 카테고리의 다른 글
빈 등록 안하고 싶을 때 - @Autowired(required = false) (0) | 2025.02.27 |
---|---|
@WithCustomMockUser - 테스트 코드 작성 시 인증 (0) | 2025.02.24 |
There were failing tests. See the report at: file:///C:/repository/ 프로젝트/build/reports/tests/test/index.html (0) | 2025.02.17 |