Skip to content

Commit

Permalink
Merge pull request #18 from potenday-project/develop
Browse files Browse the repository at this point in the history
header, cookie 허용
  • Loading branch information
HwangHoYoon authored Dec 14, 2023
2 parents abbaa0d + 74ad73f commit 36abd9f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ public class WebMvcConfig implements WebMvcConfigurer {
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("http://localhost:3000")
.allowedMethods("OPTIONS","GET","POST","PUT","DELETE");
.allowedMethods("OPTIONS","GET","POST","PUT","DELETE")
.allowedHeaders("*")
.allowCredentials(true)
;
}

}
11 changes: 11 additions & 0 deletions src/main/java/com/chwipoClova/common/filter/RequestFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,15 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
"[REQUEST] {} - {} {} - {}\n" +
"Headers : {}\n" +
"Request : {}\n" +
"Headers : {}\n" +
"Response : {}\n",
((HttpServletRequest) customRequestWrapper).getMethod(),
((HttpServletRequest) customRequestWrapper).getRequestURI(),
responseWrapper.getStatus(),
(end - start) / 1000.0,
getHeaders(customRequestWrapper),
buildAccessLog(customRequestWrapper),
getHeaders(responseWrapper),
getResponseBody(responseWrapper));
} else {
log.info("[REQUEST] {} - {} {} - {}", ((HttpServletRequest) customRequestWrapper).getMethod(), ((HttpServletRequest) customRequestWrapper).getRequestURI(), responseWrapper.getStatus(), (end - start) / 1000.0);
Expand All @@ -85,6 +87,15 @@ private Map getHeaders(HttpServletRequest request) {
return headerMap;
}

private Map getHeaders(final HttpServletResponse response) {
Map headerMap = new HashMap<>();
response.getHeaderNames().stream().forEach(s -> {
headerMap.put(s, response.getHeader(s));
});
return headerMap;
}


private String getResponseBody(final HttpServletResponse response) throws IOException {
String payload = null;
ContentCachingResponseWrapper wrapper =
Expand Down

0 comments on commit 36abd9f

Please sign in to comment.