-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
116 lines (108 loc) · 2.87 KB
/
Copy pathnext.config.ts
File metadata and controls
116 lines (108 loc) · 2.87 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import { withSentryConfig } from "@sentry/nextjs";
import type { NextConfig } from "next";
const isProd = process.env.NODE_ENV === "production";
const baseCsp = [
"default-src 'self'",
"base-uri 'self'",
"font-src 'self' data:",
"frame-ancestors 'self'",
"form-action 'self'",
"img-src 'self' data: blob: https:",
"object-src 'none'",
"style-src 'self' 'unsafe-inline'",
`script-src 'self' 'unsafe-inline'${isProd ? "" : " 'unsafe-eval'"}`,
[
"connect-src 'self'",
"https://*.ingest.sentry.io",
"https://sentry.io",
"https://api.upstash.io",
"https://*.openai.com",
].join(" "),
]
.filter(Boolean)
.join("; ");
const securityHeaders: Array<{ key: string; value: string }> = [
{ key: "Content-Security-Policy", value: baseCsp },
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
{ key: "X-Frame-Options", value: "SAMEORIGIN" },
{ key: "X-Content-Type-Options", value: "nosniff" },
{ key: "Permissions-Policy", value: "camera=(), microphone=(), geolocation=()" },
{ key: "Cross-Origin-Opener-Policy", value: "same-origin" },
{ key: "Cross-Origin-Resource-Policy", value: "same-origin" },
];
if (isProd) {
securityHeaders.push({
key: "Strict-Transport-Security",
value: "max-age=63072000; includeSubDomains; preload",
});
}
const devAllowedOrigins = process.env.NEXT_DEV_ALLOWED_ORIGINS?.split(",")
.map((origin) => origin.trim())
.filter(Boolean) ?? ["localhost", "127.0.0.1", "192.168.0.115", "172.30.10.193"];
const nextConfig: NextConfig = {
reactStrictMode: true,
poweredByHeader: false,
compress: true,
output: "standalone",
allowedDevOrigins: devAllowedOrigins,
images: {
formats: ["image/avif", "image/webp"],
remotePatterns: [
{
protocol: "https",
hostname: "avatars.githubusercontent.com",
},
{
protocol: "https",
hostname: "lh3.googleusercontent.com",
},
{
protocol: "https",
hostname: "res.cloudinary.com",
},
],
},
cacheLife: {
default: {
stale: 60,
revalidate: 5 * 60,
},
marketing: {
stale: 60 * 60,
revalidate: 24 * 60 * 60,
},
},
experimental: {
staleTimes: {
dynamic: 30,
static: 10 * 60,
},
},
serverExternalPackages: ["amqplib", "ws", "cookie"],
async headers() {
return [
{
source: "/(.*)",
headers: securityHeaders,
},
{
source: "/_next/static/(.*)",
headers: [
{
key: "Cache-Control",
value: "public, max-age=31536000, immutable",
},
],
},
];
},
};
const useSentry = Boolean(process.env.SENTRY_DSN);
const wrappedConfig = useSentry
? withSentryConfig(nextConfig, {
silent: true,
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
})
: nextConfig;
export default wrappedConfig;