Backend app is running on top of micronaut framework. Below is the error which I am getting in response.
Access to XMLHttpRequest at 'y' from origin 'x' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values 'x,x', but only one is allowed.
When the app is running as a standalone jar , it seems to be working fine. Problem occurs when it is running inside pod. Tried logging inside the pod and ran CURL command over there and it looks double headers are coming there as well.
For Micronaut I have done the below settings.
micronaut:
server:
cors:
enabled: true
Can someone point out from where those headers could be added. Ingress controller can be ruled out since in pod I can see double headers.
Did some digging on my own. Below was the analysis. Docker Image build locally give these Headers
HTTP/1.1 200 OK
Access-Control-Allow-Origin: test.com
Vary: Origin
Access-Control-Allow-Credentials: true
Date: Sat, 1 Feb 2020 13:13:47 GMT
content-type: application/json
content-length: 169
connection: keep-alive
While docker Image build via our pipeline and doing curl gives below headers
HTTP/1.1 200 OK
Access-Control-Allow-Origin: test.com
Vary: Origin
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: test.com
Vary: Origin
Access-Control-Allow-Credentials: true
Date: Sat, 1 Feb 2020 13:13:47 GMT
content-type: application/json
content-length: 169
connection: keep-alive
Please check your configuration for maven shade plugin. It should be
<execution>
<phase>install</phase>
<goals>
<goal>shade</goal>
</goals>
If you have specified it in 'package' phase then running
mvn install
mvn package
Would result in multiple entries in META-INF/services