簡體   English   中英

請求標頭字段在預檢響應中,Access-Control-Allow-Headers不允許使用If-None-Match

[英]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": nullJsonRest的標頭中為"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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM