'Access-Control-Allow-Origin' header contains multiple values 'http://localhost:4200, *', but only one is allowed

I use angular on the front end and .net5 on te backend. I deploy my backend to ubuntu 20.04 server and run it with nginx. I faced this issue while attempt to login. My get functions works well but login(post) is not. I searched hours and hours and add add_header Access-Control-Allow-Origin *; to my etc/nginx/sites-available/default file. But nothing changes. Do you have any idea?



Solution 1:[1]

Does your .NET backend allows CORS e.g have a look at https://docs.microsoft.com/en-us/aspnet/core/security/cors?view=aspnetcore-6.0

Also while you are modifying NGINX conf make sure to restart the service. e.g sudo systemctl restart nginx

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 TARJU