1

I need to download files on links clicked and window.open seemed to be a good choice. All needed was to hit this url containing filename as params.

now with login authentication in picture, how do I add authorisation headers to the window.open(url,'_blank')

  • Does this answer your question? [window.open with headers](https://stackoverflow.com/questions/4325968/window-open-with-headers) – Mikhail Zhuravlev Mar 23 '20 at 21:00
  • You can not control headers of the request made by window.open(), but you can do that with XMLHttpRequest or libraries that wrap it, like axios. Please notice that default browser logic that leads to file download won't work with XMLHttpRequest and you must initiate the download manually. – Mikhail Zhuravlev Mar 23 '20 at 21:01
  • There is an open issue for adding support for headers to the window.open function in the HTML standard. Please voice your opinions and needs on there. [https://github.com/whatwg/html/issues/7810](https://github.com/whatwg/html/issues/7810) – Dan Apr 14 '22 at 21:31

0 Answers0