Origin 'http://localhost' has been blocked by CORS policy

I get this error occasionally.

Access to XMLHttpRequest at ‘https://myUrl/cart?param=1’ from origin ‘http://localhost’ 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 ‘*, http://localhost’, but only one is allowed

  • This is my delete function
    image

How can i solve the problem?

As the error says…

its either you have the wildcard match i.e “*” or localhost but not both.