diff --git a/api-gateway/src/main/java/com/unicorn/phonebill/gateway/config/GatewayConfig.java b/api-gateway/src/main/java/com/unicorn/phonebill/gateway/config/GatewayConfig.java index 6b9527b..f71d91f 100644 --- a/api-gateway/src/main/java/com/unicorn/phonebill/gateway/config/GatewayConfig.java +++ b/api-gateway/src/main/java/com/unicorn/phonebill/gateway/config/GatewayConfig.java @@ -32,8 +32,20 @@ public class GatewayConfig { private final JwtAuthenticationGatewayFilterFactory jwtAuthFilter; - @Value("${cors.allowed-origins") + @Value("${cors.allowed-origins}") private String allowedOrigins; + + @Value("${services.user-service.url}") + private String userServiceUrl; + + @Value("${services.bill-service.url}") + private String billServiceUrl; + + @Value("${services.product-service.url}") + private String productServiceUrl; + + @Value("${services.kos-mock.url}") + private String kosMockUrl; public GatewayConfig(JwtAuthenticationGatewayFilterFactory jwtAuthFilter) { this.jwtAuthFilter = jwtAuthFilter; @@ -53,17 +65,15 @@ public class GatewayConfig { return builder.routes() // Auth Service 라우팅 (인증 불필요) .route("user-service-login", r -> r - .path("/api/auth/login", "/api/auth/refresh") + .path("/api/v1/auth/login", "/api/v1/auth/refresh") .and() .method("POST") - .filters(f -> f.rewritePath("/api/auth/(?.*)", "/api/v1/auth/${segment}")) - .uri("lb://user-service")) + .uri(userServiceUrl)) // Auth Service 라우팅 (인증 필요) .route("user-service-authenticated", r -> r - .path("/api/auth/**") + .path("/api/v1/auth/**", "/api/v1/users/**") .filters(f -> f - .rewritePath("/api/auth/(?.*)", "/api/v1/auth/${segment}") .filter(jwtAuthFilter.apply(new JwtAuthenticationGatewayFilterFactory.Config())) .circuitBreaker(cb -> cb .setName("user-service-cb") @@ -71,13 +81,12 @@ public class GatewayConfig { .retry(retry -> retry .setRetries(3) .setBackoff(java.time.Duration.ofSeconds(2), java.time.Duration.ofSeconds(10), 2, true))) - .uri("lb://user-service")) + .uri(userServiceUrl)) // Bill-Inquiry Service 라우팅 (인증 필요) .route("bill-service", r -> r - .path("/api/bills/**") + .path("/api/v1/bills/**") .filters(f -> f - .rewritePath("/api/bills/(?.*)", "/api/v1/bills/${segment}") .filter(jwtAuthFilter.apply(new JwtAuthenticationGatewayFilterFactory.Config())) .circuitBreaker(cb -> cb .setName("bill-service-cb") @@ -86,13 +95,12 @@ public class GatewayConfig { .setRetries(3) .setBackoff(java.time.Duration.ofSeconds(2), java.time.Duration.ofSeconds(10), 2, true)) ) - .uri("lb://bill-service")) + .uri(billServiceUrl)) // Product-Change Service 라우팅 (인증 필요) .route("product-service", r -> r - .path("/api/products/**") + .path("/api/v1/products/**") .filters(f -> f - .rewritePath("/api/products/(?.*)", "/products/${segment}") .filter(jwtAuthFilter.apply(new JwtAuthenticationGatewayFilterFactory.Config())) .circuitBreaker(cb -> cb .setName("product-service-cb") @@ -101,13 +109,12 @@ public class GatewayConfig { .setRetries(3) .setBackoff(java.time.Duration.ofSeconds(2), java.time.Duration.ofSeconds(10), 2, true)) ) - .uri("lb://product-service")) + .uri(productServiceUrl)) // KOS Mock Service 라우팅 (인증 불필요 - 목업용) .route("kos-mock-service", r -> r - .path("/api/kos/**") + .path("/api/v1/kos/**") .filters(f -> f - .rewritePath("/api/kos/(?.*)", "/kos/${segment}") .circuitBreaker(cb -> cb .setName("kos-mock-cb") .setFallbackUri("forward:/fallback/kos")) @@ -115,7 +122,7 @@ public class GatewayConfig { .setRetries(2) .setBackoff(java.time.Duration.ofSeconds(1), java.time.Duration.ofSeconds(5), 2, true)) ) - .uri("lb://kos-mock")) + .uri(kosMockUrl)) // 주의: Gateway 자체 엔드포인트는 라우팅하지 않음 // Health Check와 Swagger UI는 Spring Boot에서 직접 제공 diff --git a/product-service/src/main/java/com/unicorn/phonebill/product/config/SwaggerConfig.java b/product-service/src/main/java/com/unicorn/phonebill/product/config/SwaggerConfig.java index c4fbecb..8007302 100644 --- a/product-service/src/main/java/com/unicorn/phonebill/product/config/SwaggerConfig.java +++ b/product-service/src/main/java/com/unicorn/phonebill/product/config/SwaggerConfig.java @@ -50,7 +50,7 @@ public class SwaggerConfig { return GroupedOpenApi.builder() .group("product") .displayName("Product Service") - .pathsToMatch("/products/**", "/product/**") + .pathsToMatch("/api/v1/products/**", "/product/**") .build(); } diff --git a/product-service/src/main/java/com/unicorn/phonebill/product/controller/ProductController.java b/product-service/src/main/java/com/unicorn/phonebill/product/controller/ProductController.java index dca3547..87da76b 100644 --- a/product-service/src/main/java/com/unicorn/phonebill/product/controller/ProductController.java +++ b/product-service/src/main/java/com/unicorn/phonebill/product/controller/ProductController.java @@ -35,7 +35,7 @@ import java.time.LocalDate; * - 상품변경 이력 조회 */ @RestController -@RequestMapping("/products") +@RequestMapping("/api/v1/products") @Validated @Tag(name = "Product Change Service", description = "상품변경 서비스 API") @SecurityRequirement(name = "bearerAuth")