forked from yusufipk/OpenFrame
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
97 lines (91 loc) · 2.8 KB
/
Copy pathnext.config.ts
File metadata and controls
97 lines (91 loc) · 2.8 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import type { NextConfig } from 'next';
import type { RemotePattern } from 'next/dist/shared/lib/image-config';
function resolveBunnyCdnHostname(): string | null {
const raw = process.env.BUNNY_CDN_URL || process.env.NEXT_PUBLIC_BUNNY_CDN_URL;
if (!raw) return null;
try {
const parsed = new URL(raw);
return parsed.hostname || null;
} catch {
return raw.replace(/^https?:\/\//, '').replace(/\/+$/, '') || null;
}
}
const bunnyCdnHostname = resolveBunnyCdnHostname();
// Content-Security-Policy is set at request time in proxy.ts so runtime storage
// endpoints (R2_PRESIGN_ENDPOINT, etc.) are available in Docker deployments.
const securityHeaders = [
// Prevent the app from being embedded in foreign iframes (clickjacking)
{ key: 'X-Frame-Options', value: 'DENY' },
// Prevent MIME-type sniffing on all responses
{ key: 'X-Content-Type-Options', value: 'nosniff' },
// Enforce HTTPS for 2 years
{ key: 'Strict-Transport-Security', value: 'max-age=63072000; includeSubDomains' },
// microphone=(self) is required for audio comment recording; camera/geolocation unused
{ key: 'Permissions-Policy', value: 'camera=(), microphone=(self), geolocation=()' },
{ key: 'Referrer-Policy', value: 'strict-origin-when-cross-origin' },
];
const remotePatterns: RemotePattern[] = [
{ protocol: 'https', hostname: 'img.youtube.com' },
{ protocol: 'https', hostname: 'i.ytimg.com' },
{ protocol: 'https', hostname: 'images.unsplash.com' },
{ protocol: 'https', hostname: 'vz-thumbnail.b-cdn.net' },
...(bunnyCdnHostname ? [{ protocol: 'https' as const, hostname: bunnyCdnHostname }] : []),
];
const nextConfig: NextConfig = {
images: {
remotePatterns,
formats: ['image/avif', 'image/webp'],
},
experimental: {
optimizePackageImports: ['lucide-react', 'radix-ui'],
serverMinification: true,
},
poweredByHeader: false,
compress: true,
async headers() {
return [
// Global security headers applied to every response
{
source: '/(.*)',
headers: securityHeaders,
},
{
source: '/_next/static/:path*',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=31536000, immutable',
},
],
},
{
source: '/images/:path*',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=2592000',
},
],
},
{
source: '/:path*.ico',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=604800',
},
],
},
{
source: '/:path*.svg',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=2592000',
},
],
},
];
},
};
export default nextConfig;