Reputation: 71
I know that the zuul gateway can be removed by configuration, but how is springcloud-gateway implemented?
zuul: sensitive-headers: Cookie,Set-Cookie ignored-headers: Access-Control-Allow-Origin,Access-Control-Allow-Credentials
Upvotes: 3
Views: 5765
Reputation: 368
It can be done with RemoveRequestHeaderGatewayFilterFactory
or RemoveResponseHeaderGatewayFilterFactory
or RemoveHopByHopHeadersFilter
.
Please check spring-cloud-gateway guide. Choose a filter that fits your use case.
you can configure like below.
# RemoveHopByHopHeadersFilter
spring.cloud.gateway.filter.remove-hop-by-hop:
- Access-Control-Allow-Origin
- Access-Control-Allow-Credentials
# RemoveResponseHeaderGatewayFilterFactory
spring:
cloud:
gateway:
routes:
- id: test-route
uri: http://test.org
filters:
- RemoveResponseHeader= Access-Control-Allow-Origin
RemoveHopByHopHeadersFilter
is applied to all routes by default. But If you want to apply RemoveRequestHeaderGatewayFilterFactory
or RemoveResponseHeaderGatewayFilterFactory
to all routes, you have to set spring.cloud.gateway.default-filters
property.
Upvotes: 4