Configure Content Security Policy, HSTS, and other security headers via frontmcp.config or environment variables
FrontMCP applies security headers to every HTTP response, including Content Security Policy (CSP), Strict-Transport-Security (HSTS), X-Frame-Options, and X-Content-Type-Options. Configure them via frontmcp.config server settings --- they are injected as environment variables at build time and read by the built-in middleware.
Use Content-Security-Policy-Report-Only instead of enforcement
Value-less CSP directives like upgrade-insecure-requests and block-all-mixed-content are supported. Separate them with semicolons like any other directive.
X-Content-Type-Options: nosniff and X-Frame-Options: DENY are applied by default even without explicit configuration. Set them to empty strings to disable.
Use reportOnly: true to test CSP rules without blocking content:
server: { csp: { enabled: true, directives: "default-src 'self'", reportUri: 'https://report.example.com/csp', reportOnly: true, // violations are reported, not blocked },}
This sets the Content-Security-Policy-Report-Only header instead of Content-Security-Policy, allowing you to monitor violations before enforcing the policy.