DedupeResponseHeader GatewayFilter Factory

DedupeResponseHeader GatewayFilter 工厂采用一个 name 参数和一个可选的 strategy 参数。name 可以包含一个以空格分隔的头名称列表。以下示例配置一个 DedupeResponseHeader GatewayFilter

The DedupeResponseHeader GatewayFilter factory takes a name parameter and an optional strategy parameter. name can contain a space-separated list of header names. The following example configures a DedupeResponseHeader GatewayFilter:

application.yml
spring:
  cloud:
    gateway:
      routes:
      - id: dedupe_response_header_route
        uri: https://example.org
        filters:
        - DedupeResponseHeader=Access-Control-Allow-Credentials Access-Control-Allow-Origin

这在网关 CORS 逻辑和下游逻辑都添加它们的情况下,删除 Access-Control-Allow-CredentialsAccess-Control-Allow-Origin 响应标头的重复值。

This removes duplicate values of Access-Control-Allow-Credentials and Access-Control-Allow-Origin response headers in cases when both the gateway CORS logic and the downstream logic add them.

DedupeResponseHeader 过滤器还接受一个可选的 strategy 参数。接受的值为 RETAIN_FIRST(默认值)、RETAIN_LASTRETAIN_UNIQUE

The DedupeResponseHeader filter also accepts an optional strategy parameter. The accepted values are RETAIN_FIRST (default), RETAIN_LAST, and RETAIN_UNIQUE.