Website: Update response headers (#36543)

Closes: https://github.com/fleetdm/confidential/issues/11257

Changes:
- Updated the website's custom hook to set security-related response
headers for GET and HEAD requests
This commit is contained in:
Eric 2025-12-04 13:20:40 -06:00 committed by GitHub
parent 2521daa1fe
commit b9b4ba1cc9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -178,6 +178,13 @@ will be disabled and/or hidden in the UI.
throw new Error('Cannot attach view local `me`, because this view local already exists! (Is it being attached somewhere else?)');
}
res.locals.me = undefined;
// Set security headers for all GET and HEAD requests.
res.setHeader(`X-Content-Type-Options`, `nosniff`);//[?]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Content-Type-Options
res.setHeader('X-Frame-Options', 'SAMEORIGIN');// [?]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Frame-Options
res.setHeader(`Referrer-Policy`, `strict-origin-when-cross-origin`);// [?]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Referrer-Policy
res.setHeader('Strict-Transport-Security', 'max-age=31536000; includeSubDomains;');// [?]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Strict-Transport-Security
res.setHeader(`Permissions-Policy`, `camera=(), microphone=(), usb=()`);// [?]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Permissions-Policy
}//fi
// Check for query parameters set by ad clicks.