2

I'm calling an external POST request from localhost with JavaScript's fetch function.

Everything is working fine with all the browsers except for IE11, which is returning this error on the request:

“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:

Internet Options> Security > ENABLE The Following setting: Miscellaneous > Access data sources across domains.

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.

UPDATE: If I remove the headers option it works, but I need the headers.

Matheus Lima
  • 2,103
  • 3
  • 31
  • 49

1 Answers1

1

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.

Matheus Lima
  • 2,103
  • 3
  • 31
  • 49