The 'Access-Control-Allow-Origin' header contains multiple values

Hello everyone,

Because I’m making a Angular 2+ application that needs the Jira database. I need to connect to the Jira REST API. I added the .jar CORS files from http://software.dzhuvinov.com/cors-filter-installation.html to the Jira lib folder.

When I do a POST Request everything is successful. When I do a GET request with a status 401 (Not Authenticated) it also works fine.

But when I do a GET request with a success 200 the OPTIONS are successful but the actual GET request is also 200 but shows an error:

Access to XMLHttpRequest at ‘http://localhost:8080/rest/api/2/myself’ from origin ‘http://192.168.137.1’ has been blocked by CORS policy: The ‘Access-Control-Allow-Origin’ header contains multiple values ‘http://192.168.137.1, http://192.168.137.1’, but only one is allowed.

I found a solution with Apache VHOST:

SetEnvIf Origin “^https?://[^/]*(192.168.137.1|jira.inthergroup.com)$” AccessControlAllowOrigin=$0
Header set Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
Header set Access-Control-Allow-Credentials “true”

But my company is using NGINX so this doesn’t work for me. In NGINX I tried to add: add_header ‘Access-Control-Allow-Origin’ ‘*’; or to make it empty but I can only change the second value and the error is still coming up.

Does someone who also had this error or have some experience with this kind of problem know a solution for this?

Thanks in advance!