Document and Notice

March 17, 2026 ยท View on GitHub

Overall

  • Each header in config file has a reference link in phpdoc, reading it will help you knowing what the header doing.
  • If you want to disable a string type header, just set the value to null or empty string ''.

Clear Site Data

  • Clear Site Data only supports https protocol, it will not work in http protocol.

HTTP Strict Transport Security

  • After setting hsts header, you can visit https://hstspreload.org and submit request to add your domain to preload list.

Content Security Policy

You can find real world website examples in tests.

After setup csp, you should use CSP Evaluator to check up your setting.

  • If you want to allow specific protocol in directive:

    'img-src' => [
        'schemes' => [
            'data:',
            'https:',
        ],
    ],
    
  • If you want to use nonce in blade template:

    using inject

    @inject('headers', 'Bepsvpt\SecureHeaders\SecureHeaders')
    
    <style nonce="{{ $headers->nonce('style') }}">
      // your css
    </style>
    

    or calling directly

    <script nonce="{{ Bepsvpt\SecureHeaders\SecureHeaders::nonce('script') }}">
      // your js
    </script>
    

    or using helper function

    <script nonce="{{ csp_nonce('script') }}">
      // your js
    </script>
    

Testing

If you want to run testing, make sure you have the corresponding package version and minimum php version.

LaravelTestbenchPHPUnitMinimum PHP Version
5.13.15.77.0
5.23.25.77.0
5.33.35.77.0
5.43.46.57.0
5.53.56.57.0
5.63.67.57.1.3
5.73.77.57.1.3
5.83.87.57.1.3
6.x4.x8.57.2.0
7.x5.x8.57.2.5
8.x6.x9.57.3
9.x7.x9.58.0
10.x8.x9.58.1
11.x9.x10.58.2
12.x10.x11.58.2
13.x11.x11.58.3