[英]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.