Download a file through a signed URL

temporarySignedRoute plus the signed middleware. An Inertia Link cannot download the file. Use an anchor.

For your AI agent

Copies a prompt. Paste it into the AI agent you already have open.

Read https://laravel-vuejs.space/laravel-signed-download-vue.md
temporarySignedRoute plus the signed middleware. An Inertia Link cannot download the file. Use an anchor.
Do not put the signature on a public disk URL and skip can('view').
Show the diff. Do not commit.
On this page · 3 sections
  1. The fix
  2. What to avoid
  3. FAQ

People searching “Laravel signed download Vue” put the storage path in the Vue page. Generate a short-lived URL and check the policy anyway. A leaked link should expire, and it should still fail for the wrong user. The upload guide is how the file got there.

TL;DR

  • temporarySignedRoute plus the signed middleware.
  • An Inertia Link cannot download the file.
  • Use an anchor.
  • Do not put the signature on a public disk URL and skip can('view').

Who it's for: Laravel + Vue developers

Applies to: Laravel 13 · Vue 3

The fix#

php
public function show(Request $request, Post $post): Response
{
    $this->authorize('view', $post);

    return Inertia::render('posts/Show', [
        'download' => URL::temporarySignedRoute(
            'posts.download',
            now()->addMinutes(5),
            ['post' => $post->id],
        ),
    ]);
}
php
Route::get('/posts/{post}/download', function (Post $post) {
    abort_unless(auth()->user()?->can('view', $post), 403);

    return Storage::disk('local')->download($post->cover_path);
})->middleware(['auth', 'signed'])->name('posts.download');
vue
<a :href="download">Download</a>

<Link> expects an Inertia response. A file is not one, so the browser should navigate with a normal anchor.

What to avoid#

Gotcha

Do not put the signature on a public disk URL and skip can('view'). The signature proves the URL was not edited. It does not prove this user may have the file.

FAQ#

How do I download a file through a signed URL?

temporarySignedRoute plus the signed middleware. An Inertia Link cannot download the file. Use an anchor.

What goes wrong with Laravel signed download Vue?

Many developers put the storage path in the Vue page. Do not put the signature on a public disk URL and skip can('view').

Found this useful?

Ask questions, share what you built.

Join thousands of Laravel and Vue developers in our Facebook group, or get new posts in your Telegram feed. Sharing this article helps too.

Keep reading

Newsletter

Get the best of Laravel & Vue, once a month.

One short email with new guides, release notes worth reading and hand-picked community links. No spam, unsubscribe any time.