title: Zip File Download via Axios from Express Server not working in React App
body: <p>I have implemented a backend where administrators can create backups. These backups are collected in zip files and are stored in a non-public folder on the server.</p>
  <p>The administrators should be able to download the zip files afterwards. But this does not work properly. The file is downloaded, but when you try to unzip it, you get the message &quot;<strong>An attempt was made to move the file pointer before the beginning of the file</strong>&quot;. The zip file does not seem to be the problem. If you unpack it on the server, the unpacking works without errors. There must be something wrong with the download process.</p>
  <pre><code>  const downloadHandler = (params) =&gt; {
      axios.get(`/backup/download?name=${params.filename}`).then((res) =&gt; {
        const downloadUrl = window.URL.createObjectURL(new Blob([res.data]));
        const link = document.createElement('a');
        link.href = downloadUrl;
        link.setAttribute('download', 'file.zip');
        document.body.appendChild(link);
        link.click();
        link.remove();
      });
    };
  </code></pre>
  <p>The downloadHandler shown above is called in the React app as soon as a user clicks on the download button of a backup. After that the download menu of the browser opens for direct download.</p>
  <p>Server implementation:</p>
  <pre><code>router.route('/backup/download').get((req, res, next) =&gt; {
    try {
      res.download(path.join(backupPath, req.query.name));
    } catch (err) {
      next(err);
    }
  });
  </code></pre>
  <p>I have already spent hours looking for a solution, but no matter what I try, it doesn't work. The problem is, as I said, that the file cannot be unzipped after downloading.</p>