Link to home
Start Free TrialLog in
Avatar of Jason Yu
Jason YuFlag 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.
nginx.conf.txt
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jason Yu

ASKER

No, according to them, they didn't.
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
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