From 366e9d71e845e6ca69db2edbf2c7b9f0a72a2bc8 Mon Sep 17 00:00:00 2001 From: Matthias Mohr Date: Wed, 6 Sep 2023 11:52:13 +0200 Subject: [PATCH] Send auth header to same host, always open download in new window --- src/formats/format.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/formats/format.js b/src/formats/format.js index c3a87fad2..9d096d562 100644 --- a/src/formats/format.js +++ b/src/formats/format.js @@ -32,9 +32,7 @@ export class Format { tempLink.style.display = 'none'; tempLink.href = this.getUrl(); tempLink.setAttribute('download', filename ? filename : Utils.makeFileName("result", this.type)); - if (typeof tempLink.download === 'undefined') { - tempLink.setAttribute('target', '_blank'); - } + tempLink.setAttribute('target', '_blank'); document.body.appendChild(tempLink); tempLink.click(); document.body.removeChild(tempLink); @@ -62,7 +60,14 @@ export class Format { blob = await response.blob(); } else { - blob = await connection.download(url, false); + let auth = false; + try { + let apiUrl = new URL(connection.getUrl()); + let requestUrl = new URL(url); + auth = apiUrl.origin === requestUrl.origin; + } catch (error) {} + + blob = await connection.download(url, auth); } let promise = new Promise((resolve, reject) => { let reader = new FileReader();