简体   繁体   English

IE11中使用提取API的“ SCRIPT7002:XMLHttpRequest:网络错误0x80070005,访问被拒绝。”

[英]“SCRIPT7002: XMLHttpRequest: Network Error 0x80070005, Access is denied.” in IE11 with fetch API

I'm calling an external POST request from localhost with JavaScript's fetch function. 我正在使用JavaScript的fetch函数从localhost调用外部POST请求。

Everything is working fine with all the browsers except for IE11, which is returning this error on the request: 除IE11之外,其他所有浏览器都运行正常,IE11会在请求中返回此错误:

“SCRIPT7002: XMLHttpRequest: Network Error 0x80070005, Access is denied.” in IE

This is the code: 这是代码:

export const signIn = (email, password) => {
  const base64 = btoa(`${email}:${password}`);
  const headers = new Headers({
    Authorization: `Basic ${base64}`
  });
  return new Promise((resolve, reject) => {
    fetch(`${__API__}/spa/token`, {
      method: "POST",
      headers,
      credentials: "include"
    })
      .then(resp => {
        if (resp.status >= 400) {
          reject(resp);
        }
        resolve(resp);
      })
      .catch(reject);
  });
};

One of the "solutions" that I've read it this other thread ( How to solve the error "SCRIPT7002: XMLHttpRequest: Network Error 0x80070005, Access is denied." in IE ) was to change IE's configuration here: 我已在另一个线程中阅读过的“解决方案”( 如何解决IE中的错误“ SCRIPT7002:XMLHttpRequest:网络错误0x80070005,访问被拒绝。” )是在此处更改IE的配置:

Internet Options> Security > ENABLE The Following setting: Miscellaneous > Access data sources across domains. Internet选项>安全>启用以下设置:其他>跨域访问数据源。

For me, that's not a solution because I'll won't request the final user to change his/her configuration. 对我来说,这不是解决方案,因为我不会要求最终用户更改其配置。

Also, when I'm inspecting the request in IE, I can see that the POST is actually being called as a GET. 另外,当我在IE中检查请求时,可以看到POST实际上被称为GET。

UPDATE : If I remove the headers option it works, but I need the headers. 更新 :如果我删除标头选项,它可以工作,但是我需要标头。

Ok, so this was the solution for me: 好的,这就是我的解决方案:

I discovered that the issue was to send the fetch with headers. 我发现问题在于发送带有标头的提取。 If first I send it without the headers (like a preflight request) and then send it normally it just works. 如果首先我发送时没有标题(如预检请求),然后正常发送它就可以了。

Of course, this is just for IE. 当然,这仅适用于IE。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 angularjs http + script7002:xmlhttprequest:网络错误0x80070005,访问被拒绝 - angularjs http + script7002: xmlhttprequest: network error 0x80070005, access is denied SCRIPT7002:XMLHttpRequest:网络错误0x80070005,成功的预检请求后访问被拒绝 - SCRIPT7002: XMLHttpRequest: Network error 0x80070005, Access denied after successful preflight request IE10 / 11 Ajax XHR错误 - SCRIPT7002:XMLHttpRequest:网络错误0x2ef3 - IE10/11 Ajax XHR error - SCRIPT7002: XMLHttpRequest: Network Error 0x2ef3 XMLHttpRequest:网络错误0x80070005,Microsoft Edge上拒绝访问(但不是IE) - XMLHttpRequest: Network Error 0x80070005, Access is denied on Microsoft Edge (but not IE) 跨域调用错误:XMLHttpRequest:网络错误0x80070005,访问被拒绝 - Cross domain call error : XMLHttpRequest: Network Error 0x80070005, Access is denied 各种SCRIPT7002之间的区别:XMLHttpRequest:网络错误 - Difference between various SCRIPT7002: XMLHttpRequest: Network Errors asp.net MVC 4 0x80070005 - Javascript运行时错误:访问被拒绝 - asp.net MVC 4 0x80070005 - Javascript runtime error: access denied IE11中的访问被拒绝错误 - Access is denied error in IE11 IE 11错误 - 访问被拒绝 - XMLHttpRequest - IE 11 error - Access is denied - XMLHttpRequest IE11 HTTPS AJAX XMLHttpRequest:网络错误 0x2eff,由于错误 00002eff 无法完成操作 - IE11 HTTPS AJAX XMLHttpRequest: Network Error 0x2eff, Could not complete the operation due to error 00002eff
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM