Repository navigation
Expand file tree
/
Copy pathnext.config.ts
More file actions
66 lines (64 loc) · 2.33 KB
/
Copy pathnext.config.ts
File metadata and controls
66 lines (64 loc) · 2.33 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
65
66
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
async headers() {
return [
{
// Apply security headers to every route
source: "/(.*)",
headers: [
// Prevent browsers from guessing MIME types
{
key: "X-Content-Type-Options",
value: "nosniff",
},
// Block clickjacking via iframe embedding
{
key: "X-Frame-Options",
value: "DENY",
},
// Only send the origin (no path) as Referer, and never over HTTP
// This prevents email tracking pixels from learning the inbox URL
{
key: "Referrer-Policy",
value: "strict-origin-when-cross-origin",
},
// Enforce HTTPS for 1 year (only meaningful in production)
{
key: "Strict-Transport-Security",
value: "max-age=31536000; includeSubDomains; preload",
},
// Block access to camera, microphone, geolocation
{
key: "Permissions-Policy",
value: "camera=(), microphone=(), geolocation=()",
},
// Content Security Policy:
// - default-src 'self' → only load resources from our own origin
// - script-src 'self' 'unsafe-inline' 'unsafe-eval' → required for Next.js
// - style-src 'self' 'unsafe-inline' fonts.googleapis.com
// - font-src 'self' fonts.gstatic.com
// - img-src 'self' data: → allow inline data: images (email content)
// - frame-src 'none' → no iframes anywhere
// - object-src 'none' → no plugins
// - base-uri 'self' → prevent base tag injection
{
key: "Content-Security-Policy",
value: [
"default-src 'self'",
"script-src 'self' 'unsafe-inline' 'unsafe-eval'",
"style-src 'self' 'unsafe-inline' https://fonts.googleapis.com",
"font-src 'self' https://fonts.gstatic.com",
"img-src 'self' data: https:",
"frame-src 'none'",
"object-src 'none'",
"base-uri 'self'",
"form-action 'self'",
"upgrade-insecure-requests",
].join("; "),
},
],
},
];
},
};
export default nextConfig;