We help IT Professionals succeed at work.

I got "The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed. " error for an angular 2 application behind nginx server.

Jason Yu
Jason Yu asked
on
5,600 Views
Last Modified: 2018-02-16
Dear experts here:

I am working on an issue raised by our frontend web developer for his angular 2 application. The application is hosted on an nginx server with CORS configured. The Chrome throws an error and says multiple values for CORS. I am attaching the nginx configuration file in the attachment.



XMLHttpRequest cannot load http://dev-cms.avery.com/api/content/render/false/type/json/query/type:content%20+markerProductGroup-marker:6a12d922-ea1d-4a1b-8c46-3e3fbb9bcd5c. The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed. Origin 'http://localhost:4200' is therefore not allowed access.
nginx.conf.txt
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2019
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Author

Commented:
No, according to them, they didn't.

Author

Commented:
I tried to reproduce the issue on my laptop, I got the same error.

Angular is running in the development mode. Call enableProdMode() to enable the production mode.
markers:1 XMLHttpRequest cannot load http://dev-cms.avery.com/rest/product-filters. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.
main.bundle.js:1137 Response
(anonymous) @ main.bundle.js:1137
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2019

Commented:
No, according to them, they didn't.
According to who?

I put that url into an Angular app and it loads fine - see sample here

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions