24 lines
532 B
PHP
24 lines
532 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Providers;
|
|
|
|
use Illuminate\Contracts\View\View as ContractsView;
|
|
use Illuminate\Support\Facades\View;
|
|
use Illuminate\Support\Facades\Vite;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class ViewServiceProvider extends ServiceProvider
|
|
{
|
|
public function boot(): void
|
|
{
|
|
if ($this->app->runningInConsole()) {
|
|
return;
|
|
}
|
|
|
|
View::composer('*', function (ContractsView $view) {
|
|
$view->with('csp_nonce', Vite::cspNonce());
|
|
});
|
|
}
|
|
}
|