jpmurray/laravel-nofloc
jpmurray/laravel-nofloc is a Laravel package that adds the Permissions-Policy: interest-cohort=() header to opt your app out of Google FLoC cohort tracking. Simple to install and configure, it helps protect visitor privacy by default.
composer require jpmurray/laravel-nofloc. The package is tiny — one middleware class plus a service provider — so installation is effectively the whole setup. Service provider auto-discovery works on Laravel 5.5+; older apps register Jpmurray\LaravelNoFloc\LaravelNoFlocServiceProvider in config/app.php.src/. There is no config file to publish and nothing to migrate. The only decision you make is where to attach the middleware.Jpmurray\LaravelNoFloc\Http\Middleware\NoFloc — confirm the exact namespace from the README of the installed version) in app/Http/Kernel.php under web, not the global $middleware stack. It only needs to touch browser-facing HTML responses.Permissions-Policy: interest-cohort=() on every page without writing a middleware yourself. Install, register in web, then curl -sI https://yoursite.test | grep -i permissions to confirm the header is present.web group.web group, not global middleware. You do not want the header on API JSON, health checks, or static asset responses served through Laravel — it is noise and, in some strict proxy setups, can trip header-merge warnings.$this->get('/')->assertHeader('Permissions-Policy', 'interest-cohort=()'); catches the common failure where the middleware was registered in the wrong stack.X-Frame-Options, Referrer-Policy, Strict-Transport-Security, etc. Adding a second one-header middleware for a deprecated header is more moving parts than it's worth — fold the Permissions-Policy line into your existing header middleware and drop the dependency.assertHeader on a homepage smoke test) so a future refactor of Kernel.php doesn't silently drop the header.interest-cohort=() opt-out is a no-op on today's Chrome. The package still works as advertised; it just doesn't buy you anything in 2024+. Treat it as historical, not protective.Permissions-Policy (singular). The older Feature-Policy: interest-cohort=() is a different header and is ignored by browsers that implement the modern policy. If you see Feature-Policy in your output, something else is setting it.$response->headers->set('Permissions-Policy', ...) unconditionally, whichever runs last wins. There is no merge logic in this package. Search your codebase for Permissions-Policy before adding this one.php artisan cache:clear before concluding the package is broken.composer.json constraints against your Laravel version — Laravel 9/10/11 may not be in the supported range, and auto-discovery may still register but with deprecation warnings. If it doesn't install cleanly, write the five-line middleware yourself.php artisan route:list --middleware to confirm the middleware is on the route; (2) php artisan config:clear after editing Kernel.php; (3) curl a route that actually goes through the web group, not a queue or console path; (4) inspect $response->headers->all() in AppServiceProvider::boot() temporarily to see whether something is overwriting it downstream.How can I help you explore Laravel packages today?