-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
145 lines (138 loc) · 4.62 KB
/
Copy pathnext.config.ts
File metadata and controls
145 lines (138 loc) · 4.62 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import createNextIntlPlugin from "next-intl/plugin";
import type { Configuration } from "webpack";
const withNextIntl = createNextIntlPlugin();
// Temporarily disabling next-pwa as the installed version (2.0.2) is incompatible with Next.js 16
// and is missing the required 'cache' submodule.
/*
const defaultCache = require("next-pwa/cache");
const withPWA = require("next-pwa")({
dest: "public",
disable: process.env.NODE_ENV === "development",
register: true,
skipWaiting: true,
fallbacks: {
document: "/fr/offline",
},
runtimeCaching: [
{
urlPattern: /^\/api\/public\/cars/,
handler: "StaleWhileRevalidate",
options: {
cacheName: "cars-api-cache",
expiration: {
maxEntries: 50,
maxAgeSeconds: 24 * 60 * 60,
},
},
},
...defaultCache,
],
});
*/
const GLB_GLTF_REGEX = /\.(glb|gltf)$/;
const nextConfig = {
output: "standalone",
typescript: {
ignoreBuildErrors: false,
},
images: {
remotePatterns: [
{
protocol: "https",
hostname: "**.supabase.co",
pathname: "/storage/v1/object/public/**",
},
{
protocol: "https",
hostname: "lh3.googleusercontent.com",
},
{
protocol: "https",
hostname: "images.unsplash.com",
},
{
protocol: "https",
hostname: "loremflickr.com",
},
],
},
// Webpack config for 3D models
webpack: (config: Configuration) => {
if (config.module?.rules) {
config.module.rules.push({
test: GLB_GLTF_REGEX,
// biome-ignore lint/suspicious/noExplicitAny: webpack asset/resource type requires cast
type: "asset/resource" as any,
});
}
return config;
},
headers() {
const supabaseUrl =
process.env.NEXT_PUBLIC_SUPABASE_URL || "https://*.supabase.co";
const supabaseDomain = supabaseUrl.replace("https://", "");
const cspDirectives = [
"default-src 'self'",
`script-src 'self' 'unsafe-inline' ${process.env.NODE_ENV === "development" ? "'unsafe-eval'" : ""} https://www.googletagmanager.com https://www.google-analytics.com https://maps.googleapis.com`,
"style-src 'self' 'unsafe-inline' https://fonts.googleapis.com",
`img-src 'self' data: blob: ${supabaseUrl} https://*.supabase.co https://images.unsplash.com https://loremflickr.com https://maps.googleapis.com https://maps.gstatic.com https://www.googletagmanager.com https://lh3.googleusercontent.com`,
"font-src 'self' https://fonts.gstatic.com data:",
`connect-src 'self' ${supabaseUrl} https://*.supabase.co wss://${supabaseDomain} https://www.google-analytics.com https://api.chutes.ai https://maps.googleapis.com`,
"frame-src 'self' https://www.google.com https://maps.google.com",
`media-src 'self' ${supabaseUrl} https://*.supabase.co blob:`,
"object-src 'none'",
"base-uri 'self'",
"form-action 'self'",
"frame-ancestors 'self'",
"worker-src 'self' blob:",
"manifest-src 'self'",
].join("; ");
return [
{
source: "/api/:path*",
headers: [
{
key: "Access-Control-Allow-Origin",
value: process.env.ALLOWED_ORIGIN || "*",
},
{
key: "Access-Control-Allow-Methods",
value: "GET, POST, PUT, DELETE, OPTIONS",
},
{
key: "Access-Control-Allow-Headers",
value: "Content-Type, Authorization, X-Requested-With",
},
{ key: "Access-Control-Max-Age", value: "86400" },
{
key: "Cache-Control",
value: "no-store, no-cache, must-revalidate",
},
],
},
{
source: "/:path*",
headers: [
{ key: "Content-Security-Policy", value: cspDirectives },
{ key: "X-DNS-Prefetch-Control", value: "on" },
{ key: "X-Frame-Options", value: "SAMEORIGIN" },
{ key: "X-Content-Type-Options", value: "nosniff" },
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
{ key: "X-XSS-Protection", value: "1; mode=block" },
{
key: "Strict-Transport-Security",
value: "max-age=31536000; includeSubDomains; preload",
},
{
key: "Permissions-Policy",
value:
"camera=(), microphone=(), geolocation=(self), interest-cohort=()",
},
{ key: "Cross-Origin-Opener-Policy", value: "same-origin" },
],
},
];
},
};
// biome-ignore lint/suspicious/noExplicitAny: withNextIntl wrapping requires cast
export default withNextIntl(nextConfig as any);