Skip to content

Security Headers ​

HTTP security headers instruct modern web browsers to activate built-in defenses against clickjacking, MIME sniffing, cross-site scripting, and man-in-the-middle attacks.

HeaderRecommended ValueProtection
Strict-Transport-Securitymax-age=31536000; includeSubDomains; preloadEnforces HTTPS exclusively for 1 year
X-Content-Type-OptionsnosniffDisables MIME type sniffing
X-Frame-OptionsDENYPrevents framing and clickjacking
Referrer-Policystrict-origin-when-cross-originProtects sensitive URL paths from referrers
Content-Security-Policydefault-src 'self'Restricts sources of executable scripts/styles

Server Implementation ​

zig
// Adds X-Content-Type-Options, X-Frame-Options, Referrer-Policy,
// and Content-Security-Policy.
try server.use(httpx.middleware.helmet);

helmet does not set Strict-Transport-Security or Permissions-Policy. Add those in a response middleware or on the routes that need them.

Released under the MIT License.