The download attribute only works for files originating from the same origin (same domain, protocol, and port). It will not work for cross-origin URLs unless the server sends specific headers. Method 2: Configure Server HTTP Headers

ForceType application/octet-stream Header set Content-Disposition attachment Use code with caution. For Nginx servers ( nginx.conf ): Add this configuration block inside your server context:

When you click a link to a text file (.txt, .log, or .csv) in Google Chrome, the browser opens it directly in a new tab by default. While this is convenient for quick viewing, it creates extra steps if your goal is to save the file to your local hard drive.

Chrome identifies these as safe, readable formats. It renders them inside the browser tab to save local storage space and maximize speed.

The simplest developer fix is to add the download attribute directly to your HTML anchor tags. This tells the browser to download the file rather than navigate to it.