【问题标题】:Get Index Azure Search Fails 'Response for preflight has invalid HTTP status code 403'获取索引 Azure 搜索失败“预检响应具有无效的 HTTP 状态代码 403”
【发布时间】:2016-09-14 04:05:10
【问题描述】:

我之前在 this question 上发布过关于如何从 azure 搜索中提取索引架构的帖子。

我能够通过使用 Postman 的 GET Index REST API 毫无问题地提取索引架构,但是在浏览器中运行我的代码时出现错误:

XMLHttpRequest cannot load https://[service name].search.windows.net/indexes/[index name]?api-version=[api-version] Response for preflight has invalid HTTP status code 403

我只是在控制台中运行以下代码:

$.ajax({ url: 'https://[service name].search.windows.net/indexes/[index name]?api-version=[api-version]', type: 'GET', datatype: 'json', headers: {'api-key': [api-key]}})

但是,这段代码可以正常工作(返回所有数据——唯一的区别是/docs):

$.ajax({ url: 'https://[service name].search.windows.net/indexes/[index name]/docs?api-version=[api-version]', type: 'GET', datatype: 'json', headers: {'api-key': [api-key]}})

另一个奇怪的事情是 GET 索引请求的请求标头没有显示 API 密钥。

似乎 CORS(在 Azure 搜索上设置为“*”)不喜欢来自浏览器的 GET 索引请求?

欢迎任何帮助。

【问题讨论】:

标签: javascript azure cors azure-cognitive-search


【解决方案1】:

Azure 搜索不支持管理员级别的操作,例如在 CORS 请求中获取索引。见this related answer

【讨论】:

  • 谢谢...这正是我想要的。
猜你喜欢
  • 2016-04-14
  • 2016-02-08
  • 2018-04-05
  • 2018-09-22
  • 2018-09-30
  • 1970-01-01
  • 2016-02-13
  • 2018-01-25
  • 2016-12-26
相关资源
最近更新 更多