-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathnext.config.ts
More file actions
89 lines (85 loc) · 3.03 KB
/
next.config.ts
File metadata and controls
89 lines (85 loc) · 3.03 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
import type { NextConfig } from 'next';
// Internal Kong URL — only used server-side for proxying Supabase calls.
// In Docker this is http://kong:8000; locally it falls back to the public URL.
const supabaseInternalUrl = process.env.SUPABASE_URL || 'http://kong:8000';
const nextConfig: NextConfig = {
devIndicators: false,
poweredByHeader: false,
experimental: {
optimizePackageImports: [
'lucide-react',
'framer-motion',
'@radix-ui/react-dialog',
'@radix-ui/react-popover',
'@radix-ui/react-slot',
'@radix-ui/react-tooltip',
'@supabase/supabase-js',
],
},
images: {
remotePatterns: [
{ protocol: 'https', hostname: '**' },
],
},
eslint: {
ignoreDuringBuilds: true,
},
reactStrictMode: false,
productionBrowserSourceMaps: false,
output: 'standalone',
...(process.env.NODE_ENV === 'production' && {
compiler: {
removeConsole: {
exclude: ['error'],
},
},
}),
async rewrites() {
return [
{ source: '/auth/v1/:path*', destination: `${supabaseInternalUrl}/auth/v1/:path*` },
{ source: '/rest/v1/:path*', destination: `${supabaseInternalUrl}/rest/v1/:path*` },
{ source: '/storage/v1/:path*', destination: `${supabaseInternalUrl}/storage/v1/:path*` },
{ source: '/realtime/v1/:path*',destination: `${supabaseInternalUrl}/realtime/v1/:path*` },
];
},
async headers() {
const securityHeaders = [
{ key: 'X-Content-Type-Options', value: 'nosniff' },
{ key: 'X-Frame-Options', value: 'DENY' },
{ key: 'Referrer-Policy', value: 'strict-origin-when-cross-origin' },
{ key: 'Permissions-Policy', value: 'camera=(), microphone=(), geolocation=()' },
{ key: 'Strict-Transport-Security', value: 'max-age=63072000; includeSubDomains; preload' },
{ key: 'X-DNS-Prefetch-Control', value: 'on' },
// Next.js inline scripts require 'unsafe-inline'; this still blocks external script injection
{
key: 'Content-Security-Policy',
value: [
"default-src 'self'",
"script-src 'self' 'unsafe-inline' 'unsafe-eval'",
"style-src 'self' 'unsafe-inline'",
"img-src 'self' data: blob: https:",
"font-src 'self' data:",
"connect-src 'self'",
"frame-src 'self'",
"object-src 'none'",
"base-uri 'self'",
].join('; '),
},
];
return [
{
source: '/(.*)',
headers: securityHeaders,
},
{
// Allow widget pages to be iframed from any origin
source: '/w/:path*',
headers: [
...securityHeaders.filter(h => h.key !== 'X-Frame-Options' && h.key !== 'Content-Security-Policy'),
{ key: 'Content-Security-Policy', value: "frame-ancestors *; default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob: https:; font-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'self'" },
],
},
];
},
};
export default nextConfig;