axios: Axios requests not working after update from 0.19.0 to 0.21.1

Describe the issue

after updating axios from 0.19 to 0.21.1 I figure out that none of my requests are working in Firefox (it’s working on chrome and edge). Not sure how to debug that, I can’t even see my request in the network tab… reverting back to 0.19.0 make it work… there is some breaking change between that updates?

Example Code

return axios({
      url,
      method,
      headers,
      baseURL: apiBaseURL,
      params: method === 'GET' ? data : null,
      data: body,
      onUploadProgress: (progressEvent) => {
        if (progressCallback) {
          progressCallback(progressEvent)
        }
      },
      responseType: isFileDownload ? 'blob' : responseType,
    })
      .then((response) => {
        const resp = {
          is_error: response.status < 200 || response.status > 299,
          content: response.data,
        }

        if (isFileDownload) {
          RestUtils.DownloadFile(response)
        }

        return resp
      })
      .catch((error) => {
        if (error.code === 'ECONNABORTED') {
          return Promise.resolve({ is_error: false, content: [] })
        }
        if (!error.response) {
          return Promise.reject(new Error("request didn't receive a response"))
        } else {
          if (error.response.status === 401) {
            appHistory.push('/logout')
            return Promise.reject(/*new Error('Unauthorized')*/)
          }

          if (error.response.status === 403) {
            return Promise.reject({
              error: 'Action not allowed',
              statusCode: '403',
            })
          }

          return Promise.reject(error)
        }
      })

Expected behavior, if applicable

should work on Firefox with Axios 0.21.1

Environment

  • Axios Version 0.21.1
  • Adapter XHR/HTTP
  • Firefox
  • 84
  • Node.js Version [e.g. 13.0.1]
  • OS: [windows 10]
  • Additional Library Versions React 17.0.1

Additional context/Screenshots

Add any other context about the problem here. If applicable, add screenshots to help explain.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 18 (2 by maintainers)

Most upvoted comments

Also, the way axios handles error responses is a breaking change. Before it would throw if a non-200 was received. Now it does not throw so the response needs to be examined

We’re also experiencing issues with “Network Error”, SSL errors, and more errors.

But that’s what is suggested here: https://github.com/axios/axios/issues/3526#issuecomment-756041332 on January 7th 😃

So my comment deserves some emojis to make it relevant…

but others also didn’t give attention to @Crashillo comment… it is why I asked if it was intentional or is just my mistake of not properly using the lib… 😃

Previously, I did my requests like:

const headers = new Headers({
  "Content-type": "application/json"
});

After this update, Firefox throws me invalid header name

I noticed, as a workaround, that setting headers as a plain object works (also it works removing such a common header). So the issue comes up from the Headers interface.