Skip to content

Webflux: GATEWAY_ORIGINAL_REQUEST_URL_ATTR not set in ForwardRoutingFilter #4053

@FrontierPsychiatrist

Description

@FrontierPsychiatrist

This is a re-report of #3510.

Describe the bug
The documentation for Forward Routing Filter states:

The unmodified original URL is appended to the list in the ServerWebExchangeUtils.GATEWAY_ORIGINAL_REQUEST_URL_ATTR attribute

This is not the case, or I am misunderstsanding. The controller eventually handling the request (i.e. the one being forwarded to) does not see this attribute on the ServerWebExchange.

Sample
I have attached a minimal application that recreates the behavior.

It consists roughly of:

# application.yaml
spring:
  cloud:
    gateway:
      server:
        webflux:
          routes:
            - id: test
              uri: forward:/internal/test
              predicates:
                - Path=/test/**
                - Method=GET
@GetMapping("/internal/test")
public TestResponse test(ServerWebExchange exchange) {
  Set<URI> originalUris = exchange.getAttribute(ServerWebExchangeUtils.GATEWAY_ORIGINAL_REQUEST_URL_ATTR);
  return new TestResponse(true, originalUris);
}

and a test expecting the response to contain a non-null originalUris value.

forward-bug.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions