【发布时间】:2019-11-02 10:01:30
【问题描述】:
当尝试在 firefox 中发出 POST 请求时,出现以下错误消息:
跨域请求被阻止:同源策略不允许读取位于https://example.net/graphql 的远程资源。 (原因:CORS 预检通道的 CORS 标头“Access-Control-Allow-Headers”中缺少令牌“content-type”)。
跨域请求被阻止:同源策略不允许读取位于https://example.net/graphql 的远程资源。 (原因:CORS 请求未成功)。
相同的请求在 Chrome 中成功。我发送的请求是:
method: 'POST',
headers:{
'x-client-id': '123',
'content-type': 'application/json; charset=UTF-8'
},
body: JSON.stringify({
query: "query ..."
})
})
.then(res => res.json())
.then(console.log);```
I am issuing this request while on another https origin.
My setup in my code for cors is simply the spring annotation:
```@CrossOrigin(allowedHeaders = {"content-type", "x-client-id"})```
【问题讨论】:
-
尝试为该站点清除 Firefox 浏览器缓存,或强制重新加载