-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsecurity-headers.config.ts
More file actions
64 lines (60 loc) · 2.43 KB
/
Copy pathsecurity-headers.config.ts
File metadata and controls
64 lines (60 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
* Master Security Headers Configuration
*
* This file defines all security headers in a centralized location.
* These headers are used across:
* - public/_headers (Cloudflare Pages)
* - firebase.json (Firebase Hosting)
* - scripts/verify-security-headers.mjs (parity checks)
*
* DO NOT modify headers in individual files - update this master config instead.
*/
export const SECURITY_HEADERS = {
"Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload",
"X-Content-Type-Options": "nosniff",
"X-Frame-Options": "DENY",
"Referrer-Policy": "strict-origin-when-cross-origin",
"Permissions-Policy": "camera=(), microphone=(), geolocation=()",
"Cross-Origin-Opener-Policy": "same-origin-allow-popups",
"Cross-Origin-Embedder-Policy": "credentialless",
"Content-Security-Policy":
"default-src 'self'; " +
"img-src 'self' data: https://www.googletagmanager.com; " +
"script-src 'self' https://s.pageclip.co https://www.googletagmanager.com https://challenges.cloudflare.com https://cdn.jsdelivr.net; " +
"style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://s.pageclip.co; " +
"font-src 'self' https://fonts.gstatic.com; " +
"connect-src 'self' https://send.pageclip.co https://api.iconify.design https://www.googletagmanager.com https://www.google-analytics.com https://challenges.cloudflare.com https://data.your.website; " +
"frame-src 'self' https://challenges.cloudflare.com; " +
"object-src 'none'; " +
"base-uri 'self'; " +
"form-action 'self' https://send.pageclip.co; " +
"frame-ancestors 'none'; " +
"manifest-src 'self';",
} as const;
/**
* Cache control headers for different resource types
*/
export const CACHE_HEADERS = {
// Static assets (JS, CSS, SVG) - immutable, 1 year
STATIC_ASSETS: "public, max-age=31536000, immutable",
// Dynamic content like robots.txt and sitemap.xml - 1 hour
DYNAMIC_CONTENT: "public, max-age=3600",
} as const;
/**
* Convert headers object to Cloudflare Pages _headers format
*/
export function toCloudflareHeadersFormat(
headers: Record<string, string>,
): string {
return Object.entries(headers)
.map(([key, value]) => ` ${key}: ${value}`)
.join("\n");
}
/**
* Convert headers object to Firebase hosting format
*/
export function toFirebaseHeadersFormat(
headers: Record<string, string>,
): Array<{ key: string; value: string }> {
return Object.entries(headers).map(([key, value]) => ({ key, value }));
}