【发布时间】:2017-10-10 03:09:26
【问题描述】:
我正在尝试使用 Fetch API 或 request 将自定义标头 X-Query-Key 添加到 HTTP 请求,但是当我将其添加到请求的标头时,它似乎无法设置标头和 @ 987654324@ 出于某种原因设置为OPTIONS。
当我删除标题时,它会恢复为GET,因为它应该这样做。
示例代码如下所示:
const options = {
url: url,
headers: {
'Accept': 'application/json',
'X-Query-Key': '123456' //Adding this breaks the request
}
};
return request(options, (err, res, body) => {
console.log(body);
});
【问题讨论】:
-
听起来像 CORS。
标签: javascript fetch-api