Storefront Next sends security response headers by default. Every storefront that you generate from the template inherits these headers. The headers help protect shoppers from common web attacks, such as cross-site scripting (XSS), clickjacking, and protocol downgrade.
Unlike Composable Storefront (PWA Kit), which sets headers explicitly in your storefront code, Storefront Next manages these headers for you. The defaults ship from the @salesforce/storefront-next-runtime package, so you don’t maintain them yourself. To support an external integration, extend the defaults through config.server.ts or an environment variable.
Default Headers
The table lists the headers that Storefront Next sends with every page response.
max-age=15552000; includeSubDomains (sent on Managed Runtime only, and suppressed during local development)
X-Frame-Options
SAMEORIGIN
X-Content-Type-Options
nosniff
Referrer-Policy
strict-origin-when-cross-origin
Permissions-Policy
camera=(), microphone=(), geolocation=()
The headers apply to pages that your storefront renders. They don’t apply to the Managed Runtime health check, the B2C Commerce API (SCAPI) proxy path, or static assets, because other layers serve those responses.
Content Security Policy Directives
The Content Security Policy (CSP) controls which origins a page loads content from. The default policy is tuned for the Storefront Next stack: server-side rendering, Dynamic Imaging Service (DIS) images, Cloudflare Turnstile, Tailwind CSS inline styles, and SCAPI as the only outbound API origin.
Directive
Default Value
Description
default-src
'self'
Restricts every fetch type that no other directive covers.
Permits SCAPI calls and requests from the Turnstile widget.
frame-src
https://challenges.cloudflare.com
Permits the Turnstile widget iframe.
frame-ancestors
'self'
Restricts which origins can embed your storefront in a frame.
form-action
'self'
Restricts the origins that forms submit to.
base-uri
'self'
Prevents injection of a <base> element.
object-src
'none'
Blocks plugin content, such as Flash.
upgrade-insecure-requests
Enabled
Upgrades HTTP subresource requests to HTTPS.
Add Headers for an External Integration
To add an origin for an external integration, such as an analytics provider or a third-party widget, extend the defaults in config.server.ts. Import defaultCspDirectives, spread it, and add your origin to the relevant directive.
Each directive that you set replaces the default for that directive. Spread defaultCspDirectives and add your origin so that your storefront keeps the values that Storefront Next requires.
Report-only mode doesn’t block content, so it provides no protection. Don’t use report-only mode for a production deployment. To discover the origins that an integration uses, deploy with csp: { reportOnly: true } in a test environment, where the browser reports violations to the DevTools console. After you add the origins, set reportOnly to false to enforce the policy.
Warning
Override Headers with an Environment Variable
To change a header without a code change, use the PUBLIC__ environment-variable override. The variable path uses double-underscore (__) separators.
1# Turn on CSP report-only mode:2PUBLIC__app__security__headers__csp__reportOnly=true34# Turn off the Strict-Transport-Security header:5PUBLIC__app__security__headers__hsts=false
An environment variable replaces the entire directives map, not an individual directive, because the variable path uses __ as its separator and directive names contain hyphens, such as script-src. Provide the full map as a JSON value.
1# Replace the entire CSP directives map (this replaces all defaults):2PUBLIC__app__security__headers__csp__directives='{"default-src":["'"'"'self'"'"'"],"script-src":["'"'"'self'"'"'","https://cdn.example.com"]}'
Because an environment-variable override replaces all defaults, reserve it for unusual cases. For most changes, edit config.server.ts and spread defaultCspDirectives. For more information about environment-variable overrides, see Project Configuration.