mulertech/csp-bundle
Symfony bundle for managing Content Security Policy headers. Configure policies, nonces, and directives from YAML, then automatically apply CSP headers to responses with support for reporting and per-route rules.
upgrade-insecure-requests directive forced loopback-host asset requests over HTTPS, leaving local pages unstyled. This means the package now supports a credible "dogfood the real CSP in dev" workflow rather than forcing teams to disable CSP locally and discover problems only in staging. That directly informs whether you can keep Content-Security-Policy enabled on local/dev environments in your Laravel app config.upgrade-insecure-requests: false under when@dev) plus the CspHeaderBuilder::build() plainLoopbackOrigin argument gives PMs a supported path for the common case of a dev server reached at a custom name (app.test, a Laravel Sail/Valet hostname, a LAN IP for device testing). Decide whether your team standardises on the automatic loopback exemption or opts out explicitly per environment — the second is what you'd require if your local hostnames are non-loopback.trusted_proxies (which the framework perceives as plain HTTP). This is a decision you should consciously accept — it means the package prefers a slightly over-strict policy over silently weakening CSP for a misconfigured production proxy. That's the right default, but confirm your proxy configuration is correct rather than relying on the fix to cover it.BuildCspHeaderEvent now sends a policy exactly as the listener wrote it, which makes event-based customisation a dependable escape hatch. If your roadmap includes nonce handling, reporting endpoints, or per-route policies, this is the hook to build on.Adopt when:
Look elsewhere or pause when:
upgrade-insecure-requests is now omitted automatically for plain-HTTP loopback hosts. The release describes existing calls as unaffected, and they are at the API level, but if you assert on exact header strings in tests running against localhost, expect those assertions to need updating. Pin versions and review minor releases if your test suite is strict about header contents.To executives: This is a small, focused library that applies a security header (Content-Security-Policy) to our Laravel app's responses. The latest release fixes a real defect: on local development servers, Safari was blocking our stylesheets and images, so developers saw broken pages and lost time. It's fixed with a tightly scoped rule that only affects genuine local development addresses (localhost, 127.0.0.1, ::1) — production policies are unchanged, including for sites served over HTTP or sitting behind a proxy. Investment: minimal. Return: fewer "works on my machine" incidents and a security header we can keep switched on everywhere, including during development.
To engineering: v3.2.0 is additive at the API level — build() takes an optional plainLoopbackOrigin argument, existing calls compile and behave the same. The substantive change is that upgrade-insecure-requests is now omitted when a page is served over plain HTTP to a loopback host, because Safari applies the directive there and Chrome/Firefox don't. The exemption checks the host, not the scheme, so public HTTP sites and TLS-terminating proxies not listed in trusted_proxies keep the directive — if you see the directive unexpectedly retained behind a proxy, fix trusted_proxies rather than working around the package. Policies set via BuildCspHeaderEvent are now sent verbatim. If you run a dev server under a non-loopback name (app.test, LAN IP), set upgrade-insecure-requests: false under when@dev as the README describes. Check any tests that assert on exact header strings for loopback hosts.
How can I help you explore Laravel packages today?