joelbutcher / socialstream

OAuth for Laravel, simplified.

Home Page:https://docs.socialstream.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[bug] StreamedResponse not possible

siedi opened this issue · comments

commented

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:

  1. Have Laravel Nova installed
  2. Within the user resource, add an action like this:
    public function actions(NovaRequest $request)
    {
        return [
            ExportAsCsv::make(),
        ];
    }

  1. 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
commented

Solved with the 4x version