Reputation: 23
iam using spring boot gateway with eureka server but when i try to reach some api from gateway it dose not take the path of gateway route it takes the service name
@Configuration
public class SpringCloudConfig {
@Bean
public RouteLocator gatewayRoutes(RouteLocatorBuilder builder) {
return builder.routes()
// .route("book", r -> r.path("/book/**").uri("lb://BOOKS"))
.route("bookstore", r -> r.path("/booksstore/**").uri("lb://BOOKSTORE"))
.route("book",
r -> r.path("/book/**")
.uri("lb://BOOKS"))
.build();
}
}
but if i replace "book" with "books" (service name) it will work
Upvotes: 2
Views: 599
Reputation: 1094
According to your configuration, api-gateway by URI "lb://BOOKS" gets from eureka server the path to your service "http://ххх.ххх.ххх.ххх:8080/", and your service seems to have an endpoint "/books", not "/book".
Accordingly, you need to change the endpoint in your remote service to "/book".
Upvotes: 1