Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 6 additions & 16 deletions nginx/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,19 @@ server {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;

# 모든 요청에 대해 CORS 헤더를 한 번만 추가
add_header 'Access-Control-Allow-Origin' 'https://qrumble.vercel.app' always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, PATCH, DELETE, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type, Accept' always;

# OPTIONS (Preflight) 요청에 대한 처리
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' "$http_origin" always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, PATCH, DELETE, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type, Accept' always;
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}

if ($http_origin ~* ^(https://qrumble.vercel.app)$) {
add_header 'Access-Control-Allow-Origin' "$http_origin" always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
}

# add_header 'Access-Control-Allow-Origin' "$http_origin" always;
# add_header 'Access-Control-Allow-Credentials' 'true' always;
# add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, PATCH, DELETE, OPTIONS' always;
# add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type, Accept' always;


}
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/efub/cpbr/crumble/auth/service/AuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public User signup(SignUpRequestDto signUpRequestDto) {
.password(encodedPassword)
.email(signUpRequestDto.getEmail())
.nickname(signUpRequestDto.getNickname())
.role(RoleType.USER) // 기본 역할 USER로 설정
.point(0) // 초기 포인트 0으로 설정
.isActive(true) // 계정 활성화 상태로 설정
.role(RoleType.USER)
.point(0)
.isActive(true)
.build();

User savedUser = userRepository.save(newUser);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ public JwtAuthenticationFilter(JwtTokenProvider jwtTokenProvider) { // 생성자
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {

String path = request.getRequestURI();

// 인증이 필요 없는 API 경로들을 건너뜀.
if (path.startsWith("/auth/login") || path.startsWith("/auth/signup") || path.startsWith("/auth/token")) {
filterChain.doFilter(request, response);
return;
}

try {
String token = resolveToken(request);

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/efub/cpbr/crumble/user/entity/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public User(Long userId, String username, String password, String email, String
this.point = (point == 0) ? 0 : point; // 기본값 처리
this.isActive = isActive;
this.role = (role == null) ? RoleType.USER : role; // 기본 역할 처리
this.profileImageIndex = profileImageIndex;
this.profileImageIndex = profileImageIndex; // 이 부분 유지
}

/*public void deactivate() { // 사용자 탈퇴
Expand Down