3

The following works in Chrome, but gives Network Error in IE 11. Same with using Fetch instead of Axios. What am I missing?

async componentDidMount() {
    var auth = "Basic " + btoa(process.env.REACT_APP_CREDENTIAL);
    var state = this;

    Axios.get(
      process.env.REACT_APP_URL,
      {
        headers: {
          Accept: "application/json",
          "Content-Type": "application/json",
          Authorization: auth,
        },
        withCredentials: true,
      }
    )
      .then(function (response) {
        console.log(response.status);
        state.setState({ data: response.data.value });
      })
      .catch(function (error) {
        console.log(error);
      });
  }

error image

jose praveen
  • 1,298
  • 2
  • 10
  • 17
Nick
  • 186
  • 1
  • 5
  • Why not including error message in your post? It might be useful. – Danko Apr 03 '20 at 19:05
  • Just added as screenshot of the error, which indicates it's a Permission Denied error. However, the credentials I'm passing in are correct and this works in Chrome with no errors. Why and how to fix? – Nick Apr 03 '20 at 19:32
  • Try to clear the browser data(cache, cookie and so on) or [reset IE browser setting](https://support.microsoft.com/en-us/help/17441/windows-internet-explorer-change-reset-settings) and check whether it works well. Besides, perhaps this is might be a CORS issue. Try to use F12 developer tools to check the request and response body, and compare them in Chrome and IE browser. Then, perhaps we have to add the CORS manually. – Zhi Lv Apr 06 '20 at 08:08
  • 1
    I'm not seeing the request and response headers in IE 11 or Edge. Tried adding Pragma: "no-cache, no-store" and "Cache-Control": "no-cache, no-store" to the headers, but still nothing. Also, tried adding Access-Control-Allow-Origin: * to headers as well. Still no luck. When drilling down the error, it looks like Axios is passing through the headers in IE and Edge. If it's a CORS issue, wouldn't it affect Chrome as well? I've added Access-Control-Allow-Origin: * on the server as well. Still the same Network Error in IE and Edge. – Nick Apr 06 '20 at 16:57
  • Try to refer o the following steps: Open Internet Option, select the Security tab, then select the Local intranet and click “sites”, in the popup window, click Advanced button, Add here your domain or localhost, finally click the close button and save change. Then, re-Open IE/Edge and test your code. If still not working, you could also check the IE/Edge browser proxy setting, make sure they are not using a proxy server. – Zhi Lv Apr 09 '20 at 08:55
  • Just tried all that and confirmed not using any proxy. Unfortunately, still no luck. – Nick Apr 09 '20 at 20:08
  • Try to [detect the IE browser using JavaScript](https://stackoverflow.com/questions/19999388/check-if-user-is-using-ie), then using JQuery Ajax to send the request in IE browser, and using Axios method in other browsers. – Zhi Lv Apr 15 '20 at 09:52
  • I am facing the same issue, any idea how to fix it? – Subhendu Kundu May 21 '20 at 16:53

0 Answers0