![](/img/trans.png)
[英]Request header field Access-Control-Allow-Headers is not allowed by Access-Control-Allow-Headers in preflight response
[英]Request header field If-None-Match is not allowed by Access-Control-Allow-Headers in preflight response
使用dojo/store/JsonRest
发布到REST API时,我收到以下错误。 我正在使用"X-Requested-With": null
以避免预检请求,但我仍然收到此错误。
API完全支持CORS。
有什么想法可以修复吗?
请求标头字段在预检响应中,Access-Control-Allow-Headers不允许使用If-None-Match。
var store = new JsonRest({
target: 'https://api.xxx.com/data',
headers: {
"Authorization": 'Bearer ' + 'd4c72611fc43ab44a46344d907a2b96964df2c91',
"X-Requested-With": null // no prefligh
}
});
store.get('1-00').then(function (data) {
// ok works here
console.log('get', data)
});
// post request
store.add({name:'test'}).then(function (data) {
// error here
console.log('add', data)
});
我能够使用"If-None-Match": null
解决此问题"If-None-Match": null
在JsonRest
的标头中为"If-None-Match": null
。
有关"If-None-Math"
有趣文档可以在HTTP / 1.1规范中找到 。
var store = new JsonRest({
target: 'https://api.xxx.com/data',
headers: {
"Authorization": 'Bearer ' + 'd4c72611fc43ab44a46344d907a2b96964df2c91',
"X-Requested-With": null`, // no prefligh
"If-None-Match": null // solve my issue
}
});
store.get('1-00').then(function (data) {
// ok works here
console.log('get', data)
});
// post request
store.add({name:'test'}).then(function (data) {
// ok works here
console.log('add', data)
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.