next-forge uses next-secure-headers to set HTTP response headers related to security.

Configuration

Here are the headers we have enabled:

PropertyHeaderDescriptionValue
forceHTTPSRedirectStrict-Transport-SecurityPrevents browsers from connecting to your site over HTTP.[true, { maxAge: 63_072_000, includeSubDomains: true, preload: true }]
frameGuardX-Frame-OptionsPrevents browsers from rendering your site in an iframe.deny
noopenX-Download-OptionsPrevents browsers from automatically opening downloaded files in the same origin as the page.noopen
nosniffX-Content-Type-OptionsPrevents browsers from MIME-sniffing a response away from the declared content type.nosniff
xssProtectionX-XSS-ProtectionPrevents browsers from executing inline scripts if a cross-site scripting attack is detected.sanitize
contentSecurityPolicyContent-Security-PolicySets a policy to prevent a wide range of different types of attacks, including Cross Site Scripting (XSS) and data injection attacks.false
expectCTExpect-CTEnables a mechanism to mitigate the risk of fraudulent certificates being used in connections to your site.false
referrerPolicyReferrer-PolicyControls how much of the full URL is included in the Referer header.false
The forceHTTPSRedirect property has been customized from the default to include subdomains and preload the HSTS policy. This should allow you to submit your site at hstspreload.org without any issues.

Usage

The headers are enabled by default when using the next-config package. If you are customizing your next.config.ts file, you can extend the headers manually.