Issue
I am using Spring Gateway framework and configured as follows.
gateway:
default-filters:
- DedupeResponseHeader=Access-Control-Allow-Origin
globalcors:
cors-configurations:
'[/**]':
allowedOrigins: "*"
allowedMethods: "*"
allowedHeaders: "*"
But when I try to execute a request on the gateway, I get the following error.
has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed.
I do not understand how to configure the configuration to avoid this error
Solution
Try with this configuration:
gateway:
default-filters:
- DedupeResponseHeader=Access-Control-Allow-Origin Access-Control-Allow-Credentials, RETAIN_UNIQUE
globalcors:
cors-configurations:
'[/**]':
allowed-origins: "*"
allowed-methods: "*"
allowed-headers: "*"
allow-credentials: true
Answered By - Pablo Aragonés
Answer Checked By - Dawn Plyler (JavaFixing Volunteer)