XMLHttpRequest抛出csrf错误响应

时间:2018-04-10 10:02:38

标签: javascript xmlhttprequest

我正在尝试创建XMLHttpRequest。我的请求失败,403(禁止)错误说

detail:"CSRF Failed: Referer checking failed - Referer is insecure while host is secure."  

这就是我提出请求的方式。我的令牌是正确的。

 var xhr = new XMLHttpRequest();
            xhr.withCredentials = true;

            xhr.addEventListener("readystatechange", function () {
                if (this.readyState === 4) {
                    console.log(this.response);
                    console.log("success")
                    //that.afterFaceAdded(response.id);
                }
            });

            xhr.open("PUT", url);
            xhr.setRequestHeader("authorization", "Token " + that.props.token_Reducer.token);
            xhr.setRequestHeader("content-type", "application/json");


            xhr.send(data);

0 个答案:

没有答案