1

I’m trying to make a GET request in order to query data from Azure Search service. I am trying to follw this tutorial:https://www.dotnetcurry.com/microsoft-azure/cognitive-search-rest-apis-angular-app

How can I allow my domain to make a successful GET request without being blocked by CORS policy.

enter image description here Is there a possible way or custom configuration on Azure to allow default sites to bypass this error? I have tried to add the API key as a parameter to the URL but the same problem raised again.

Thank you

Gridi Kono
  • 25
  • 6

1 Answers1

5

You see this message because your browser blocks requests going to host samplecognitive.search.windows.net which is different from the origin localhost. You must tell Azure Search to send back a "Access-Control-Allow-Origin" header including localhost.

In the Overview tab of Azure Search Service go to "Indexes" and click on your index. Then go to "CORS". Add http://localhost:4200 and click "Save".

enter image description here

Christian Vorhemus
  • 2,396
  • 1
  • 17
  • 29