Introduction:
Ever built a “Download Report” button that broke when you added authentication? You’re not alone. Frontend file delivery seems simple until you hit CORS errors, authentication walls, or dynamic content generation. Let’s dissect three battle-tested download techniques — from basic links to controlled blob workflows — with modern code that solves real production headaches.
1. The <a> Tag: Simplicity with Hidden Traps
Why “simple” doesn’t mean robust
HTML5’s download
attribute feels magical until cross-origin requests fail silently. This method works best for public assets like static PDFs or images.
<!-- Good for same-origin downloads -->
<a href="/invoices/2023.pdf" download="Q4-Report.pdf">Download PDF</a>
<!-- Danger zone: Cross-origin requires server cooperation -->
<a href="https://external.com/data.csv" download>
<!-- May open in browser instead of downloading -->
</a>
I’ve seen teams waste days debugging why this “simple” solution failed — always verify
Access-Control-Allow-Origin
headers for external resources.
2. Window Navigation: When You Don’t Control Filenames
Learn more Beyond the Download Button: Frontend File Strategies That Actually Scale