Skip to content

Commit

Permalink
Merge pull request #131 from yooonwodyd/weekly
Browse files Browse the repository at this point in the history
Weekly
  • Loading branch information
yooonwodyd authored Nov 15, 2024
2 parents 2c76231 + ad34949 commit 21765eb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,25 @@ public class CorsLoggingFilter extends OncePerRequestFilter {
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {

// 요청 헤더 로깅
// 요청 헤더 로깅, cors
String origin = request.getHeader("Origin");
if (origin != null) {
logger.info("Request Origin Header: {}", origin);
}

String requestMethod = request.getHeader("Access-Control-Request-Method");
if (requestMethod != null) {
logger.info("Access-Control-Request-Method Header: {}", requestMethod);
}

// 필터 체인을 통해 요청 처리
filterChain.doFilter(request, response);

// 응답 헤더 로깅
logger.info("Response Headers:");
// 모든 응답 헤더 로깅
logger.info("Logging all Response Headers:");
response.getHeaderNames().forEach(headerName -> {
String headerValue = response.getHeader(headerName);
logger.info("{}: {}", headerName, headerValue);
logger.info("Response Header -> Name: '{}', Value: '{}'", headerName, headerValue);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.sessionManagement((session) -> session
.sessionCreationPolicy(SessionCreationPolicy.STATELESS));
http.cors(withDefaults());

http.authorizeHttpRequests((authorize) ->
authorize
.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll()
Expand Down Expand Up @@ -104,5 +103,4 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
public BCryptPasswordEncoder bCryptPasswordEncoder() {
return new BCryptPasswordEncoder();
}

}

0 comments on commit 21765eb

Please sign in to comment.