Avatar of Jason Yu
Jason Yu
Flag for United States of America asked on

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.

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.
Chrome* NginxWeb Browsers

Avatar of undefined
Last Comment
Julian Hansen

8/22/2022 - Mon
Julian Hansen

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Jason Yu

No, according to them, they didn't.
Jason Yu

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
Julian Hansen

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
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes