Skip to content

Conversation

@Lucki2g
Copy link
Contributor

@Lucki2g Lucki2g commented Dec 20, 2025

No description provided.

1. X-DNS-Prefetch-Control: on
Purpose: Controls DNS prefetching for external resources
Protection: Allows the browser to proactively resolve domain names in the background, improving performance while still being safe when set to "on"
2. Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
Purpose: Forces browsers to only connect via HTTPS
Protection: Prevents man-in-the-middle attacks by ensuring all communication is encrypted
Details:
max-age=63072000 = 2 years
includeSubDomains = applies to all subdomains too
preload = allows inclusion in browser HSTS preload lists
3. X-Frame-Options: SAMEORIGIN
Purpose: Controls whether your site can be embedded in iframes
Protection: Prevents clickjacking attacks where attackers embed your site in a malicious iframe
Details: SAMEORIGIN allows framing only from your own domain
4. X-Content-Type-Options: nosniff
Purpose: Prevents browsers from MIME-type sniffing
Protection: Stops browsers from interpreting files as a different MIME type than declared (e.g., executing a text file as JavaScript)
Result: Reduces XSS attack surface
5. X-XSS-Protection: 1; mode=block
Purpose: Enables browser's built-in XSS filter
Protection: Blocks pages when cross-site scripting attacks are detected
Note: Legacy header (modern browsers use CSP instead), but provides defense-in-depth for older browsers
6. Referrer-Policy: strict-origin-when-cross-origin
Purpose: Controls what referrer information is sent with requests
Protection: Prevents leaking sensitive information in URLs
Details: Sends full URL for same-origin requests, only origin for cross-origin HTTPS requests, nothing for HTTP downgrades
7. Permissions-Policy: camera=(), microphone=(), geolocation=(), interest-cohort=()
Purpose: Controls which browser features and APIs can be used
Protection: Disables unnecessary permissions that could be exploited
Details:
camera=() = no camera access
microphone=() = no microphone access
geolocation=() = no location tracking
interest-cohort=() = disables FLoC tracking (privacy protection)
8. Content-Security-Policy (CSP)
This is the most important and complex header. Let me break down each directive:
default-src 'self'
Default policy: only allow resources from your own domain
script-src 'self' 'unsafe-eval' 'unsafe-inline'
Scripts: Allow from your domain
'unsafe-eval': Allows eval() - needed for Next.js development/runtime
'unsafe-inline': Allows inline <script> tags - needed for Next.js
style-src 'self' 'unsafe-inline'
Styles: Allow from your domain and inline styles (needed for React/Next.js)
img-src 'self' data: https:
Images: Allow from your domain, data URIs (base64 images), and any HTTPS source
font-src 'self' data:
Fonts: Allow from your domain and data URIs
connect-src 'self'
API calls/WebSockets: Only allow connections to your own domain
frame-ancestors 'self'
Embedding: Similar to X-Frame-Options, only allow your own domain to frame your site
base-uri 'self'
Base tag: Prevent injection of <base> tags that could redirect relative URLs
form-action 'self'
Form submissions: Only allow forms to submit to your own domain
@Lucki2g Lucki2g merged commit 1f60380 into main Dec 20, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants