Repository navigation
Expand file tree
/
Copy pathnext.config.js
More file actions
122 lines (118 loc) · 2.97 KB
/
Copy pathnext.config.js
File metadata and controls
122 lines (118 loc) · 2.97 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
117
118
119
120
121
122
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
const withPWA = require('@ducanh2912/next-pwa').default({
dest: 'public',
register: true,
skipWaiting: true,
disable: process.env.NODE_ENV === 'development',
buildExcludes: [/middleware-manifest\.json$/],
runtimeCaching: [
{
urlPattern: /^https:\/\/res\.cloudinary\.com\/.*/i,
handler: 'CacheFirst',
options: {
cacheName: 'cloudinary-images',
expiration: {
maxEntries: 200,
maxAgeSeconds: 30 * 24 * 60 * 60, // 30 days
},
},
},
{
urlPattern: /^\/api\/.*/i,
handler: 'NetworkFirst',
options: {
cacheName: 'api-cache',
networkTimeoutSeconds: 10,
expiration: {
maxEntries: 50,
maxAgeSeconds: 5 * 60, // 5 minutes
},
},
},
{
urlPattern: /\.(?:png|jpg|jpeg|svg|gif|webp)$/i,
handler: 'CacheFirst',
options: {
cacheName: 'image-cache',
expiration: {
maxEntries: 100,
maxAgeSeconds: 30 * 24 * 60 * 60, // 30 days
},
},
},
{
urlPattern: /\/_next\/image\?url=.*/i,
handler: 'StaleWhileRevalidate',
options: {
cacheName: 'next-image-cache',
expiration: {
maxEntries: 200,
maxAgeSeconds: 30 * 24 * 60 * 60, // 30 days
},
},
},
],
});
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
turbopack: {}, // Silence Turbopack warning
experimental: {
// Keep defaults; no experimental flags needed right now
},
images: {
minimumCacheTTL: 2592000, // 30 days cache for optimized images
// Allow Cloudinary hosted images (QR codes, avatars, etc.)
remotePatterns: [
{
protocol: "https",
hostname: "res.cloudinary.com",
port: "",
pathname: "**",
},
{
protocol: "https",
hostname: "**.mm.bing.net",
port: "",
pathname: "**",
},
],
},
async rewrites() {
// Proxy API to backend so cookies are same-site in dev
const backend = process.env.NEXT_PUBLIC_BACKEND_URL || "http://localhost:5000";
return [
{
source: "/api/:path*",
destination: `${backend}/api/:path*`,
},
];
},
async headers() {
return [
{
// Apply these headers to all routes in your application.
source: "/(.*)",
headers: [
{
key: "X-Content-Type-Options",
value: "nosniff",
},
{
key: "Referrer-Policy",
value: "strict-origin-when-cross-origin",
},
{
key: "Content-Security-Policy",
// This is a moderately strict CSP that allows Next.js to function (unsafe-eval for dev, unsafe-inline for styles)
// while restricting framing and ensuring resources are loaded securely.
value: "default-src 'self'; script-src 'self' 'unsafe-eval' 'unsafe-inline' https:; style-src 'self' 'unsafe-inline' https:; img-src 'self' blob: data: https:; font-src 'self' data: https:; connect-src 'self' http: https: ws: wss:; frame-ancestors 'none';",
},
],
},
];
},
};
module.exports = withBundleAnalyzer(withPWA(nextConfig));