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.
nginx.conf.txt
Jason YuAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
Are you not adding another header in your actual script?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jason YuAuthor Commented:
No, according to them, they didn't.
0
Jason YuAuthor 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
0
Julian HansenCommented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Chrome

From novice to tech pro — start learning today.