[bug] StreamedResponse not possible
siedi opened this issue · comments
Describe the bug
We are using laravel nova in the latest version and want to use their csv download function
https://nova.laravel.com/docs/4.0/resources/#csv-export
The error is:
local.ERROR: JoelButcher\Socialstream\Http\Middleware\ShareInertiaData::handle(): Return value must be of type Illuminate\Http\Response|Illuminate\Http\RedirectResponse|Illuminate\Http\JsonResponse, Symfony\Component\HttpFoundation\StreamedResponse returned {"userId":"01h19vw4m9jkd0pjtt3pmqbjmw","exception":"[object] (TypeError(code: 0): JoelButcher\Socialstream\Http\Middleware\ShareInertiaData::handle(): Return value must be of type Illuminate\Http\Response|Illuminate\Http\RedirectResponse|Illuminate\Http\JsonResponse, Symfony\Component\HttpFoundation\StreamedResponse returned at /var/www/html/vendor/joelbutcher/socialstream/src/Http/Middleware/ShareInertiaData.php:35)
Seems like a fix could be in the file
joelbutcher/socialstream/src/Http/Middleware/ShareInertiaData.php:35
add StreamedResponse
as a possible response
use Symfony\Component\HttpFoundation\StreamedResponse;
public function handle(Request $request, Closure $next): Response|RedirectResponse|JsonResponse|StreamedResponse
To Reproduce
Steps to reproduce the behavior:
- Have Laravel Nova installed
- Within the user resource, add an action like this:
public function actions(NovaRequest $request)
{
return [
ExportAsCsv::make(),
];
}
- In the nova frontend, try to trigger the action
Expected behavior
The CSV downloads works
Environment context
- Socialstream version: 5.5
- Jetstream stack: Inertia
- Laravel version: 9.19
- PHP version: 8.1
Solved with the 4x version