Nonce support for the scripts Filament renders

Nonce support for the scripts Filament renders

  • security
  • csp
  • assets
PR #20301 by @m-develops

If your application sends a Content Security Policy header, you can now share Laravel's Vite CSP nonce with Filament (and Livewire) via Vite::useCspNonce($nonce) so scripts rendered through FilamentAsset, including window.filamentData carry a nonce. Styles still need 'unsafe-inline'; this is scripts only.

use Illuminate\Support\Facades\Vite;

Vite::useCspNonce($nonce);

You can usually call this in the middleware that creates the policy.

All Filament Up To Date tips