Helmet middleware helps secure your Fiber applications by setting various HTTP security headers to protect against common web vulnerabilities.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/gofiber/fiber/llms.txt
Use this file to discover all available pages before exploring further.
Installation
Signatures
Usage
Basic Usage
Custom Configuration
HSTS Configuration
Content Security Policy
Configuration
Function to skip this middleware when it returns true.
Value for the
X-XSS-Protection header. Modern browsers use CSP instead.Value for the
X-Content-Type-Options header. Prevents MIME type sniffing.Value for the
X-Frame-Options header. Possible values: SAMEORIGIN, DENY, ALLOW-FROM uri.max-age value in seconds for the Strict-Transport-Security header. Set to 0 to disable HSTS.When set to true, the
includeSubDomains directive is not added to HSTS header.Value for the
Content-Security-Policy header. Empty string disables CSP.When true, uses
Content-Security-Policy-Report-Only header instead.When true, adds the
preload directive to HSTS header.Value for the
Referrer-Policy header.Value for the
Permissions-Policy header (formerly Feature-Policy).Value for the
Cross-Origin-Embedder-Policy header.Value for the
Cross-Origin-Opener-Policy header.Value for the
Cross-Origin-Resource-Policy header.Value for the
Origin-Agent-Cluster header.Value for the
X-DNS-Prefetch-Control header.Value for the
X-Download-Options header.Value for the
X-Permitted-Cross-Domain-Policies header.Default Configuration
Best Practices
Production Configuration
Testing CSP with Report-Only Mode
Common Patterns
API-Only Application
Conditionally Apply Headers
Disable Specific Headers
Testing
Security Headers Explained
- X-Content-Type-Options: Prevents browsers from MIME-sniffing responses
- X-Frame-Options: Protects against clickjacking attacks
- Strict-Transport-Security: Enforces HTTPS connections
- Content-Security-Policy: Controls which resources the browser can load
- Referrer-Policy: Controls how much referrer information is shared
- Permissions-Policy: Controls which browser features can be used
- Cross-Origin-*-Policy: Provides isolation between cross-origin resources