Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Mike V
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 11, 2018

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?

You will be a great help because this is my internship project and it would be great if I could put it online.

 

Thanks in advance! 

1 answer

0 votes
Jose Maria Gonzalez Vazquez
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 18, 2019

If you are developing from local you might need to add a CORS extension to your browser to allow it. If not it will need a domain to trust you.

Suggest an answer

Log in or Sign up to answer