Skip to content

securityHeaders

securityHeaders: (options?) => Function

Defined in: http/security-headers.js:58

Creates a security headers middleware that returns pre-computed header tuples.

Pass false for any header to omit it entirely. Pass a string to override the default value.

Security header configuration

string | false

Content-Security-Policy header

string

Permissions-Policy header (omitted by default)

string | false

Referrer-Policy header

string | false

Strict-Transport-Security header. Defaults to false because this middleware has no request context to verify the connection is HTTPS, and HSTS MUST only be sent over secure transport (RFC 6797 §7.2). Enable explicitly when the app is known to be behind HTTPS, or use ergo-router’s transport layer which performs the HTTPS check automatically.

string | false

X-Content-Type-Options header

string | false

X-Frame-Options header

string | false

X-XSS-Protection header (0 disables the browser filter)

Function

  • Ergo middleware () => Array<[string, string]>