Skip to content

Fix ForwardRoutingFilter missing original request URL attribute#4081

Open
lly835 wants to merge 1 commit intospring-cloud:mainfrom
lly835:fix/issue-4053
Open

Fix ForwardRoutingFilter missing original request URL attribute#4081
lly835 wants to merge 1 commit intospring-cloud:mainfrom
lly835:fix/issue-4053

Conversation

@lly835
Copy link
Copy Markdown

@lly835 lly835 commented Feb 28, 2026

Summary

When a route uses forward: URI, ForwardRoutingFilter forwarded the exchange without adding the original request URL into GATEWAY_ORIGINAL_REQUEST_URL_ATTR.
This caused handlers/controllers receiving the forwarded ServerWebExchange to miss the documented original URL attribute.

This change adds the original incoming request URI before dispatching to DispatcherHandler.

Changes

  • In ForwardRoutingFilter, call addOriginalRequestUrl(exchange, exchange.getRequest().getURI()) before handle(...).
  • Add unit test shouldAddOriginalRequestUrlAttributeWhenForwarding in ForwardRoutingFilterTests.

Testing

  • ./mvnw -pl spring-cloud-gateway-server-webflux -Dtest=ForwardRoutingFilterTests test
  • ./mvnw -pl spring-cloud-gateway-server-webflux -Dtest=ForwardRoutingFilterTests,ForwardRoutingFilterStaticIntegrationTests test

Both passed locally on JDK 21.

Fixes #4053

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Webflux: GATEWAY_ORIGINAL_REQUEST_URL_ATTR not set in ForwardRoutingFilter

2 participants