This version is still in development and is not considered stable yet. For the latest stable version, please use Spring Cloud Gateway 4.1.6!

RemoveRequestHeader GatewayFilter Factory

The RemoveRequestHeader filter takes a name parameter. It is the name of the header to be removed. The following listing configures a RemoveRequestHeader filter:

application.yml
spring:
  cloud:
    gateway:
      mvc:
        routes:
        - id: removerequestheader_route
          uri: https://example.org
          filters:
          - RemoveRequestHeader=X-Request-Foo
GatewaySampleApplication.java
import static org.springframework.cloud.gateway.server.mvc.filter.BeforeFilterFunctions.removeRequestHeader;
import static org.springframework.cloud.gateway.server.mvc.handler.GatewayRouterFunctions.route;
import static org.springframework.cloud.gateway.server.mvc.handler.HandlerFunctions.http;

@Configuration
class RouteConfiguration {

    @Bean
    public RouterFunction<ServerResponse> gatewayRouterFunctionsremoveRequestHeader() {
		return route("removerequestheader_route")
				.GET("/**", http("https://example.org"))
					.before(removeRequestHeader("X-Request-Foo"))
					.build();
    }
}

This removes the X-Request-Foo header before it is sent downstream.