【发布时间】: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