This covers the six-header baseline plus the redirect/rewrite
pattern from Chapter 4's first case study. It assumes a static
or prerendered single-page app with no per-request CSP nonce --
suitable for a site that does not need to protect an inline
script with anything stronger than a hash or
'unsafe-inline'.
{
"framework": "vite",
"buildCommand": "npm run build",
"outputDirectory": "dist",
"headers": [
{
"source": "/(.*)",
"headers": [
{
"key": "Content-Security-Policy",
"value": "default-src 'self'; base-uri 'self'; object-src 'none'; frame-ancestors 'none'; form-action 'self'; script-src 'self' 'unsafe-inline' https://your-cdn-or-tag-manager.example.com; style-src 'self' 'unsafe-inline'; img-src 'self' data: https://your-cdn-or-tag-manager.example.com; connect-src 'self' https://your-analytics.example.com; frame-src 'self'; font-src 'self' data:; upgrade-insecure-requests"
},
{ "key": "X-Content-Type-Options", "value": "nosniff" },
{ "key": "X-Frame-Options", "value": "DENY" },
{ "key": "Referrer-Policy", "value": "strict-origin-when-cross-origin" },
{ "key": "Permissions-Policy", "value": "camera=(), microphone=(), geolocation=()" },
{ "key": "Strict-Transport-Security", "value": "max-age=63072000; includeSubDomains" }
]
}
],
"redirects": [
{ "source": "/old-page", "destination": "/new-page", "permanent": true },
{ "source": "/old-page/", "destination": "/new-page", "permanent": true }
],
"rewrites": [
{ "source": "/(.*)", "destination": "/index.html" }
]
}