-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
80 lines (74 loc) · 3.08 KB
/
Copy pathnext.config.ts
File metadata and controls
80 lines (74 loc) · 3.08 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
import type { NextConfig } from "next";
const csp = [
"default-src 'self'",
"script-src 'self' 'unsafe-eval' 'unsafe-inline'", // Next.js requires eval for dev, inline for chunks
"style-src 'self' 'unsafe-inline'", // Tailwind + framer-motion inline styles
"img-src 'self' data: blob: https://*.supabase.co https://m.media-amazon.com https://logo.clearbit.com https://*.hkrtcdn.com",
"font-src 'self' data: https://fonts.gstatic.com",
"connect-src 'self' https://*.supabase.co https://*.upstash.io",
"frame-ancestors 'self'",
"base-uri 'self'",
"form-action 'self'",
].join("; ");
const securityHeaders = [
{ key: "X-DNS-Prefetch-Control", value: "on" },
{ key: "Strict-Transport-Security", value: "max-age=63072000; includeSubDomains; preload" },
{ key: "X-Frame-Options", value: "SAMEORIGIN" },
{ key: "X-Content-Type-Options", value: "nosniff" },
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
{ key: "Permissions-Policy", value: "camera=(), microphone=(), geolocation=(), interest-cohort=()" },
{ key: "Content-Security-Policy", value: csp },
];
const nextConfig: NextConfig = {
// ── Vercel Remote Caching ─────────────────────────────────────
// Using default in-memory cache for stability.
// ISR will not persist across deployments without a remote cache.
// cacheHandler: process.env.VERCEL ? "./cache-handler.mjs" : undefined,
// cacheMaxMemorySize: 0,
// ── Incremental Static Regeneration ──────────────────────────
// Static pages revalidate on demand (no build-time generation).
// Fresh data = stale-while-revalidate pattern via the ISR cache.
experimental: {
// Disable persistent cache to avoid stale compiled output during dev
turbopackFileSystemCacheForDev: false,
},
images: {
remotePatterns: [
{ protocol: "https", hostname: "m.media-amazon.com" },
{ protocol: "https", hostname: "logo.clearbit.com" },
{ protocol: "https", hostname: "*.media-amazon.com" },
{ protocol: "https", hostname: "img8.hkrtcdn.com" },
{ protocol: "https", hostname: "img6.hkrtcdn.com" },
{ protocol: "https", hostname: "*.hkrtcdn.com" },
{ protocol: "https", hostname: "*.supabase.co" },
],
formats: ["image/avif", "image/webp"],
minimumCacheTTL: 86400,
},
async headers() {
return [
{
source: "/(.*)",
headers: securityHeaders,
},
{
source: "/sw.js",
headers: [
{ key: "Content-Type", value: "application/javascript" },
{ key: "Cache-Control", value: "no-cache, no-store, must-revalidate" },
{ key: "Service-Worker-Allowed", value: "/" },
],
},
{
source: "/manifest.json",
headers: [
{ key: "Content-Type", value: "application/manifest+json" },
{ key: "Cache-Control", value: "public, max-age=3600" },
],
},
];
},
compress: true,
poweredByHeader: false,
};
export default nextConfig;