Search code examples
c#asp.netasp.net-corecors

The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed. cors error not resolving


Access to XMLHttpRequest at 'https://apicredit2fa.devserver.co.in/api/adminaccount/signin' from origin 'http://localhost:3000' has been blocked by CORS policy

Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed.

I cofigured the default cores and using middleware app.UseCors(); as well

I tried with fixed cores but getting * and core name . multiple error remains


Solution

  • The error

    The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed.

    indicates there're mutipule 'Access-Control-Allow-Origin' in your response headers

    and if you configured AllowAnyOrigin() when you regist cros,it would add 'Access-Control-Allow-Origin' :"*" to your response header, try remove AllowAnyOrigin() and observe if there're any other error or check if you added the header anwhere else again

    If you still have problem,please show us a minimal example that could reproduce the error