filament-impersonate icon indicating copy to clipboard operation
filament-impersonate copied to clipboard

Issues with custom middleware

Open therajumandapati opened this issue 5 months ago • 1 comments

Similar to the issue reported in https://github.com/stechstudio/filament-impersonate/issues/75, I'm experiencing it as well.

Symfony\Component\HttpFoundation\Response::setContent(): Argument #1 ($content) must be of type ?string, Illuminate\Routing\Redirector given, called in [redacted]/vendor/laravel/framework/src/Illuminate/Http/Response.php on line 73

This is only happening in my case because I have a middleware.

public function handle(Request $request, Closure $next): Response
    {
	    if(!empty(auth()->user())){
		    // session value set on login
		    setPermissionsTeamId(auth()->user()->org_id);
	    }
        return $next($request);
    }

The error is triggered by the return call within this middleware. Since the Impersonator is returning a redirect response, it doesn't seem to work with the way Laravel 11 middlewares are created.

Any thoughts?

therajumandapati avatar Sep 03 '24 11:09 therajumandapati