Skip to Content
Senri

Security headers

Add security headers at once with secureHeaders()

import { ,  } from "@senrijs/senri";

const  = ();

.(());

// change, remove or add headers
.(
    ({
        : "DENY",
        : false,
        : "default-src 'self'",
    }),
);

For each header, a string sets that value, true or omitting it uses the default, and false leaves it out.

Added by default

HeaderDefault
Cross-Origin-Opener-Policysame-origin
Cross-Origin-Resource-Policysame-origin
Origin-Agent-Cluster?1
Referrer-Policyno-referrer
Strict-Transport-Securitymax-age=15552000; includeSubDomains
X-Content-Type-Optionsnosniff
X-DNS-Prefetch-Controloff
X-Download-Optionsnoopen
X-Frame-OptionsSAMEORIGIN
X-Permitted-Cross-Domain-Policiesnone
X-XSS-Protection0 (turns off the legacy XSS filter)

Content-Security-Policy and Cross-Origin-Embedder-Policy break apps easily, so they are not added by default. They are added only when given a string (true throws).

Options

Prop

Type

On this page