Skip to content

Commit be49cc3

Browse files
committed
[CICD] nginx.conf 및 SpringSecurity 수정
1 parent 505fdc9 commit be49cc3

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

nginx.conf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,14 @@ server {
1111

1212
location / {
1313

14-
# 요청을 내부 스프링 앱(8080 포트)으로 전달하는 것은 동일합니다.
14+
# 요청을 내부 스프링 앱(8080 포트)으로 전달
1515
proxy_pass http://127.0.0.1:8080;
16+
17+
add_header 'Access-Control-Allow-Origin' 'http://localhost:3000' always;
18+
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
19+
add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type, *' always;
20+
add_header 'Access-Control-Allow-Credentials' 'true' always;
21+
1622
proxy_set_header Host $host;
1723
proxy_set_header X-Real-IP $remote_addr;
1824
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

src/main/java/fitfit/domain/token/filter/JwtAuthenticationFilter.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import jakarta.servlet.http.HttpServletRequest;
77
import jakarta.servlet.http.HttpServletResponse;
88
import lombok.RequiredArgsConstructor;
9+
import org.springframework.http.HttpMethod;
910
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
1011
import org.springframework.security.core.context.SecurityContextHolder;
1112
import org.springframework.security.core.userdetails.UserDetails;
@@ -59,6 +60,10 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
5960

6061
@Override
6162
protected boolean shouldNotFilter(HttpServletRequest request) throws ServletException {
63+
if (request.getMethod().equalsIgnoreCase(HttpMethod.OPTIONS.name())) {
64+
return true;
65+
}
66+
6267
// 더 안정적인 AntPathMatcher.match() 로 수정
6368
return WHITE_LIST.stream().anyMatch(white -> antPathMatcher.match(white, request.getRequestURI()));
6469
}

0 commit comments

Comments
 (0)