How to download file from URL in React without opening preview

Viewed 116

So far I have already seen a lot of questions where this type of question were asked but none of works in my case.

I would like to tell you in the first place is The Server Side is Not Mine! means the URL were from another source!

What I've tried is -


I have tried to add download attr in the anchor tag or <a href="urlhere" download></a> It will just open a new page with preview also tried with react Link none of them worked!


And tried with these libraries file-saver, js-file-downloader, same issues!


when trying one of those things I got an error saying -

Access to XMLHttpRequest at 'urlOfDownloadingfile' from origin 'http://localhost:3000'
has been blocked by CORS policy: No 'Access-Control-Allow-Origin'
header is present on the requested resource. 

I think because the server-side is not controlled by me so that's why it is happening!

Is there any way I can solve this issue!

Any help will be always appreciated!

0 Answers
Related