Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blob: urls rejected #4677

Closed
juanevp opened this issue May 5, 2022 · 10 comments · Fixed by #4678
Closed

blob: urls rejected #4677

juanevp opened this issue May 5, 2022 · 10 comments · Fixed by #4678

Comments

@juanevp
Copy link

juanevp commented May 5, 2022

Describe the bug

axios throws ERR_BAD_REQUEST (message: Unsupported protocol blob:) when processing a url with scheme blob:

To Reproduce

This code:

const blob = new Blob(["some content"]);
const url = URL.createObjectURL(blob);
const response = await axios.get(url, {responseType: "blob"});

generates a blob url (eg, blob:http://localhost:3001/01296a6c-a41f-49b1-b59e-af71729dbb6b) which axios rejects as having an invalid scheme. But the browser supports such urls and it was working alright until #3544 which started restricting the schemes accepted.

Expected behavior

Accept the request.

Environment

  • Browser
  • axios 0.26.1 and later.

Additional context/Screenshots

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

@jasonsaayman
Copy link
Member

Closed and merged

@maxstue
Copy link

maxstue commented May 10, 2022

@jasonsaayman Hi wenn will this fix be published on npm? because on my project we are facing the same issue. We could downgrade to 0.26 but I would rather wait some days and upgrade

@skout90
Copy link

skout90 commented Jul 25, 2022

0.27.2 version has same problem.

@krisliew
Copy link

On version 0.27.2, I am getting the same error as above with responseType: "arraybuffer"

@nathantaal
Copy link

Any updates? This seems still to be an issue.

@arpitha-jaanaki
Copy link

arpitha-jaanaki commented Jan 30, 2023

any updates on "Unsupported protocol blob" as im facing the same issue on "axios version ": ^0.27.2"

kindly let me know if any solution figured out !..

have a look below for the image which shows error.

image

@maxstue
Copy link

maxstue commented Jan 31, 2023

@arpitha-jaanaki i think this is fixed in version 1.x and up, you should use that one and test if it still occurs

@arpitha-jaanaki
Copy link

HI
used version v1.3.0 and this is fixed

thanks for the suggestion.

@arpitha-jaanaki
Copy link

hi above error got fixed but axios with version greater than 1.0.0 has some error too that it shows "Cannot use import statement outside a module " for import Axios from 'axios';

how to fix this new, solution tried : added type :"module" in package.json file

@maxstue
Copy link

maxstue commented Feb 7, 2023

@arpitha-jaanaki If you are inside a browser environment(react/vue,...), you need to add "type="module" to your script tag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants