Azure Search (search.windows.net) No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin is therefore not allowed access. The response had HTTP status code 400.

When using Azure Search you may come across the following error when trying to reach the api

No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin is therefore not allowed access. The response had HTTP status code 400

The problem is that search.windows.net will not allow cross origin requests by default and you have to tell it to allow them per index. When creating the index add the following section to your configuration:

"corsOptions": (optional) { 
   "allowedOrigins": ["*"] | ["origin_1", "origin_2", ...], 
   "maxAgeInSeconds": (optional) max_age_in_seconds (non-negative integer) 
   }

From Create Index (Azure Search API)

comments powered by Disqus