Skip to content

[6.x] Fix CP downloads for Inertia requests on inertia-laravel 3.5.2 - #15697

Merged
jasonvarga merged 1 commit into
6.xfrom
fix-inertia-download-location
Oct 21, 2026
Merged

jasonvarga merged 1 commit into
6.xfrom
fix-inertia-download-location

Conversation

@jasonvarga

Copy link
Copy Markdown
Member

inertia-laravel 3.5.2 (inertiajs/inertia-laravel#919) changed its empty response check from empty($response->getContent()) to $response->getContent() === ''. Streamed and binary file responses return false from getContent(), so they no longer reach onEmptyResponse(). Our override there, which converts CP downloads into Inertia::location() visits so the browser can handle them, stopped running. This is what's failing HandleInertiaRequestsTest in CI.

This moves the conversion into handle() by wrapping $next, so downloads are converted before the parent middleware sees the response. It can't simply check after parent::handle(), because older versions would already have turned the download into a redirect back by then.

Behaviour is unchanged on inertia-laravel 2.x and 3.x (tested on 2.0.28, 3.5.1 and 3.5.2). The only difference is that the 409 location response now also carries the Vary: X-Inertia header.

inertia-laravel 3.5.2 no longer passes streamed and binary file responses to onEmptyResponse, so downloads were no longer converted into location visits. Convert them before the parent middleware handles the response, which works across all supported versions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jasonvarga
jasonvarga merged commit 8d6196f into 6.x Oct 21, 2026
65 checks passed
@jasonvarga
jasonvarga deleted the fix-inertia-download-location branch October 21, 2026 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant