filamentphp / filament

A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS.
https://filamentphp.com
MIT License
18.72k stars 2.91k forks source link

Can't use Filament components on 404 pages #14519

Open simonhamp opened 1 week ago

simonhamp commented 1 week ago

Package

filament/filament

Package Version

v3.2.116

Laravel Version

v11.27.1

Livewire Version

v3.5.6

PHP Version

v8.3.11

Problem description

My error page template is customised so that it's not the standard Laravel 404 page. It's set to use my main layouts/app.blade.php and the page renders using this layout.

This layout includes @filamentStyles and @filamentScripts with the intention being to make use of some Filament components on the page, but when I hit a non-existent page, @filamentScripts fails to load any scripts needed for Filament to operate - they also 404.

If I swap it to use @livewireScripts, everything works.

So it looks like the @filamentScripts tag is preventing loading of these assets on a 404 somehow.

Expected behavior

I expect Livewire, Alpine and Filament scripts to be available to my page whether it's 404 or not.

Steps to reproduce

Create a errors/404.blade.php file that includes @filamentScripts, then visit a URL that isn't handled by a route in your application. See that the necessary <script> tags rendered but result in a 404 header and aren't loaded.

Screenshot 2024-10-14 at 15 30 56


Swap @filamentScripts for @livewireScripts and note that the behaviour is different.

Screenshot 2024-10-14 at 15 33 10

Reproduction repository (issue will be closed if this is not valid)

https://github.com/simonhamp/filament-scripts

Relevant log output

No response

Donate 💰 to fund this issue

Fund with Polar

awcodes commented 1 week ago

Run php artisan filament:assets manually.

Doing this in your repo app loads them correctly on the 404.

simonhamp commented 2 hours ago

@awcodes i haven't tried this yet, but can you enlighten me as to why this works?

Feels really strange to me to have separate behaviour.