fix: Allow public access to docs API and handle NoResourceFoundException smoothly

This commit is contained in:
jade
2026-07-07 10:25:07 +09:00
parent 65367b24cb
commit ee8a168240
2 changed files with 8 additions and 1 deletions

View File

@@ -22,7 +22,8 @@ public class WebConfig implements WebMvcConfigurer {
.addPathPatterns("/rpc/**", "/mcp/api/v1/**") // /rpc/, /mcp/api/v1/ 로 시작하는 모든 API는 API Key 검사 수행! .addPathPatterns("/rpc/**", "/mcp/api/v1/**") // /rpc/, /mcp/api/v1/ 로 시작하는 모든 API는 API Key 검사 수행!
.excludePathPatterns( .excludePathPatterns(
"/test/**", "/health", "/error", "/mcp/api/v1/admin/**", "/test/**", "/health", "/error", "/mcp/api/v1/admin/**",
"/swagger-ui/**", "/v3/api-docs/**", "/swagger-resources/**", "/webjars/**" // Swagger UI 경로는 인증 제외 "/swagger-ui/**", "/v3/api-docs/**", "/swagger-resources/**", "/webjars/**", // Swagger UI 경로는 인증 제외
"/mcp/api/v1/tools/docs/markdown", "/favicon.ico"
); );
} }

View File

@@ -11,6 +11,12 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
@RestControllerAdvice // 이 어노테이션이 전역 적용의 핵심입니다! @RestControllerAdvice // 이 어노테이션이 전역 적용의 핵심입니다!
public class GlobalExceptionHandler { public class GlobalExceptionHandler {
@ExceptionHandler(org.springframework.web.servlet.resource.NoResourceFoundException.class)
public ResponseEntity<Void> handleNoResourceFound(org.springframework.web.servlet.resource.NoResourceFoundException e) {
log.warn(" [Gateway Not Found] 요청하신 리소스를 찾을 수 없습니다: {}", e.getResourcePath());
return ResponseEntity.notFound().build();
}
@ExceptionHandler(IllegalArgumentException.class) @ExceptionHandler(IllegalArgumentException.class)
public ResponseEntity<JsonRpcResponse> handleIllegalArgument(IllegalArgumentException e) { public ResponseEntity<JsonRpcResponse> handleIllegalArgument(IllegalArgumentException e) {
log.warn(" [Gateway Bad Request] 잘못된 요청: {}", e.getMessage()); log.warn(" [Gateway Bad Request] 잘못된 요청: {}", e.getMessage());