Skip to content

Regression in 0.19.0: file:/// that always returns a status code 0 now returns an error  #2396

@gierschv

Description

@gierschv

Describe the bug

Since I upgrade axios from 0.18.0 to 0.19.0, the requests made to fetch a local file (file:///) with a relative path return an error: Request failed with status code 0. However the web browser will always return a status code 0 when the request success because there is no HTTP server involved. The XHR readyState is also 4, if there was a network error, I believe this one would probably be 0 as well.

To Reproduce

// In a HTML file like opened at file:///tmp/axios.html for example
axios.get('./file.ttf', {
  responseType: 'arraybuffer',
}).then((resp) => {
  console.log('OK', resp);
}).catch((err) => {
  if (err.request && err.request.readyState === 4) {
     //  The response here should not be treated as an error
  }
  console.log('ERR', err);
});

Expected behavior
The request should success and return the arraybuffer (works with axios 0.18.0).

Environment:

  • Axios Version: 0.19.0
  • OS: iOS 12.4, OSX 10.14.6
  • Browser: Safari
  • Browser Version: 12.1.2
  • Additional Library Versions: None

Additional context/Screenshots
Screenshot 2019-09-07 at 13 26 37
Screenshot 2019-09-07 at 13 31 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions