spring-cloud-gateway icon indicating copy to clipboard operation
spring-cloud-gateway copied to clipboard

gateway version above 4.1.6 local rest handler stopped working

Open chengtangzheng2021 opened this issue 7 months ago • 3 comments

Describe the bug my gateway app has local rest handler, they were working very well with version of gateway 4.1.6 and before 4.1.6, above 4.1.6 local rest handler stopped working.

Sample with these in pom <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> 3.5.0 <relativePath/> <java.version>17</java.version> <spring-cloud.version>2025.0.0</spring-cloud.version> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-gateway-server-webflux</artifactId>

chengtangzheng2021 avatar Jun 16 '25 23:06 chengtangzheng2021

@Bean
public RouteLocator myRoutes(RouteLocatorBuilder builder) {
	return builder.routes()
			.route("facadeCheckBodyV3",
					r -> r.method("POST").and()
							.path("/api/v3/facades/itp-v3-emulator/dell/dependantpricingcatalog/**")
							.or().path("/api/v4/facades/itp-v3-emulator/dell/dependantpricingcatalog/**").and()
							.readBody(String.class, requestBody -> true)
							.filters(f -> f.filter(facadeFilter)).uri("no://op"))

					r -> r.path("/v3/api-docs").or().path("/v3/api-docs/swagger-config")
							.filters(f -> f.filter(swaggerFilter)).uri("no://op"))
			.route("check-query", r -> r.path("/**").filters(f -> f.filter(queryFilter)).uri("no://op"))
			.build();

this routing also not working above gateway version 4.1.6

chengtangzheng2021 avatar Jun 16 '25 23:06 chengtangzheng2021

@RestController public class ForwardedToController { private static final Logger logger = LoggerFactory.getLogger(ForwardedToController.class)

@GetMapping("/health")
public ResponseEntity<String> health() {
	return ResponseEntity.ok("{\"status\": \"OK\"}");
}

}

local rest handler

chengtangzheng2021 avatar Jun 17 '25 00:06 chengtangzheng2021

@chengtangzheng2021 please stop closing and opening new issues. One will suffice, with editing or new comments.

If you'd like us to spend some time investigating, please take the time to provide a complete, minimal, verifiable sample (something that we can unzip attached to this issue or git clone, build, and deploy) that reproduces the problem. Random bits of code in comments is not sufficient.

spencergibb avatar Jun 17 '25 01:06 spencergibb

got it working, some dependencies versions issue

chengtangzheng2021 avatar Jun 19 '25 00:06 chengtangzheng2021

got it working, some dependencies versions issue

Me too facing an issue relating to no://op after migrating to Spring Cloud 2025.0.0. Curious, what was the fix in your case?

spring.cloud.gateway:
          routes:
          - id: nopGateway
            uri: no://op

changed to

spring.cloud.gateway:
          server.webflux.routes:
          - id: nopGateway
            uri: no://op

By some reason, org.springframework.cloud.gateway.route.RouteDefinitionRouteLocator#loadGatewayFilters is not getting called for id nopGateway

Omkar-Shetkar avatar Oct 06 '25 08:10 Omkar-Shetkar