Issue with ExportAction error 403

I'm trying to setup an export for a resource, i managed to follow the documentation and solve the issues caused by the fact i have 3 tables which can authenticate on the system (sadly it's a legacy thing and I can't change it).
I reached the point where the file is created but when i try to download it i always get error 403, i think the issue is caused by the fact that it doesn't recognize the Admin model as the current Auth user or is that it doesn't recognize the /filament/exports/{export}/download route as being under filament
i tried to override it through a custom middleware but it's still not working.

Route::get('/filament/exports/{export}/download', DownloadExport::class)
    ->name('filament.exports.download')
    ->middleware([FilamentAccess::class]);


class FilamentAccess
{
    /**
     * Handle an incoming request.
     *
     * @param  \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response)  $next
     */
    public function handle(Request $request, Closure $next): Response
    {
        if (! Filament::auth()->check()) {
            return redirect()->route('filament.admin.auth.login');
        }

        /** @var \App\Models\Admin */
        $user = Filament::auth()->user();

        if (! $user || !($user instanceof \App\Models\Admin)) {
            abort(403, 'You do not have access to the admin panel.');
        }

        return $next($request);
    }
}
Solution
Apparently all I had to do was using the auth:admin middleware
Route::get('/filament/exports/{export}/download', DownloadExport::class)
    ->name('filament.exports.download')
    ->middleware([
        'web', 'auth:admin',
       FilamentAccess::class
    ]);
Was this page helpful?