A practical walkthrough for replacing raw S3 bucket URLs with clean, proxied paths in a Laravel application. The approach uses a centralized URL helper class and a streaming proxy controller (~20 lines) that serves files from private or public S3-compatible buckets via `/storage/{disk}/{path}` routes. Key benefits include hiding storage provider details, supporting private buckets without signed URLs, and setting 24-hour CDN cache headers via Cloudflare. The post also covers middleware adjustments to avoid overriding custom Cache-Control headers and notes the memory advantage of `readStream()` over `Storage::download()`.

4m read timeFrom danielpetrica.com
Post cover image
Table of contents
The architectureStep 1: Build a URL helperStep 2: The proxy controllerStep 3: Route and middleware setupStep 4: Wire it up everywhereWhat about the admin panel?The result
12.7K Impressions1 Comment