0

When trying to call List Indexes endpoint of Search API, seeing a CORS error on pre flight request during development,

API - https://learn.microsoft.com/en-us/rest/api/searchservice/list-indexes

Console error How can we add I local host as allowed origin in azure search API ?

I did take a look at the existing open bugs but not helping

CORS issues on Azure Search Service

CORS issues on Azure Search

Calling the list indexes api from local host

API - https://learn.microsoft.com/en-us/rest/api/searchservice/list-indexes

1 Answers1

0

For query API's you can follow the below steps:

  1. Go to the Azure Portal
  2. Go to your Search service resource
  3. On the Overivew blade, click Indexes and navigate to your index
  4. Go to the CORS tab, select the Custom radio button
  5. Type "https://localhost:44321" in the Allowed Origins text area

enter image description here

Alternatively, you can use the REST API to update your Index Definition in the corsOptions property. `

"corsOptions": {
    "allowedOrigins": ["https://localhost:44321"]
}

`

https://learn.microsoft.com/rest/api/searchservice/create-index#request-body

However, as listed in the docs, "For security reasons, only query APIs support CORS. If you want to do other operations such as List Indexes, you will need to setup a proxy to workaround CORS if you wish to list indexes from a website.

Farzzy - MSFT
  • 290
  • 1
  • 10