"DedupeResponseHeader" not working with Greenwich.SR3

Viewed 751

DedupeResponseHeader is not working for me in Spring Cloud Greenwich.SR3, I have added CORS configuration in application.yml, and downstream application is also sending Access-Control-Allow-Origin in response header, which in ending up with:

The 'Access-Control-Allow-Origin' header contains multiple values 'http://localhost:4200, http://localhost:4200', but only one is allowed.

enter image description here

I have used DedupeResponseHeader but that is not working for me still seeing same error in browser console. Following is the config for CORS and DedupeResponseHeader:

spring:
  cloud:    
   gateway:
    default-filters:
    - DedupeResponseHeader=Access-Control-Allow-Origin, RETAIN_UNIQUE
    globalcors:
      add-to-simple-url-handler-mapping: true
      corsConfigurations:
        '[/**]':
          allowedOrigins: "http://localhost:4200"
          allowedMethods: "*"
          allowedHeaders: "*"

Tried in filters also, but also didn't work

spring:   
  cloud:    
    gateway:
      routes:
      - id: dedupe_response_header_route
        uri: http://localhost:4200
        predicates:
        - Method=OPTIONS
        - Method=GET
        filters:
        - DedupeResponseHeader=Access-Control-Allow-Origin

Couldn't figure out the reason why its not working, double checked the spring cloud version. I appreciate, if someone could help to understand why DedupeResponseHeader not working.

1 Answers

You can use the latest version of the spring cloud i.e. 2020.0.2 --- it is working perfectly there.

Related