Skip to content

Commit 5d5476f

Browse files
won-seoopclaude
andcommitted
GH-1949: Document that overriding discovery locator filters replaces all defaults
Add an IMPORTANT callout to make it clear that setting spring.cloud.gateway.discovery.locator.filters replaces the entire default filter list, meaning the RewritePath filter must be explicitly re-declared or downstream services will receive the unstripped path and return 404. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 53921a8 commit 5d5476f

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

docs/modules/ROOT/pages/spring-cloud-gateway-server-webflux/the-discoveryclient-route-definition-locator.adoc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@ The default filter is a rewrite path filter with the regex `/serviceId/?(?<remai
1919
This strips the service ID from the path before the request is sent downstream.
2020

2121
If you want to customize the predicates or filters used by the `DiscoveryClient` routes, set `spring.cloud.gateway.discovery.locator.predicates[x]` and `spring.cloud.gateway.discovery.locator.filters[y]`.
22-
When doing so, you need to make sure to include the default predicate and filter shown earlier, if you want to retain that functionality.
22+
23+
[IMPORTANT]
24+
====
25+
Setting `spring.cloud.gateway.discovery.locator.filters` *replaces* the entire default filter list.
26+
If you only add your own filters without re-declaring `RewritePath`, the service ID will *not* be stripped from the path and requests will fail with a `404` on the downstream service.
27+
Always include the default `RewritePath` filter when defining custom filters, as shown in the examples below.
28+
====
29+
2330
The following examples shows what this looks like in properties and yaml format:
2431

2532
.application.properties

0 commit comments

Comments
 (0)