【发布时间】:2019-08-06 21:35:07
【问题描述】:
谷歌了一个小时,但找不到任何提示我在这里缺少什么。
This fiddle 在 Chrome 中运行良好,但 Firefox 甚至没有尝试发送 OPTIONS 请求。
fetch("http://localhost:8080/mutate?commitNow=true", {
method: "POST",
body: '{"set": { "name": "Alice" }}',
//headers: {"Content-Type": "application/json"},
headers: [ ["Content-Type", "application/json"] ]
})
firefox de 工具中没有发出网络请求,我已经确认服务器没有收到任何请求。 在 Chrome 中,同样的小提琴确实发送了预检和请求。 如果我注释掉自定义标题,它也开始在 Firefox 中正常工作。但我需要设置内容类型。
如何让 Firefox 使用 CORS fetch 发送自定义标头?
控制台中的错误信息是:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:8080/mutate?commitNow=true. (Reason: CORS request did not succeed).
此消息没有帮助,因为甚至没有尝试过请求(见上文)
【问题讨论】:
标签: firefox