-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
61 lines (56 loc) · 1.99 KB
/
Copy pathnext.config.ts
File metadata and controls
61 lines (56 loc) · 1.99 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
import type { NextConfig } from "next";
import { initOpenNextCloudflareForDev } from "@opennextjs/cloudflare";
initOpenNextCloudflareForDev();
const r2Hostname = process.env.R2_ACCOUNT_ID
? `${process.env.R2_ACCOUNT_ID}.r2.cloudflarestorage.com`
: null;
const r2Pathname = process.env.R2_BUCKET_NAME
? `/${process.env.R2_BUCKET_NAME}/**`
: "/**";
const isDevelopment = process.env.NODE_ENV === "development";
const contentSecurityPolicy = [
"default-src 'self'",
`script-src 'self' 'unsafe-inline'${isDevelopment ? " 'unsafe-eval'" : ""}`,
"style-src 'self' 'unsafe-inline'",
"img-src 'self' blob: data: https:",
"media-src 'self' blob: https:",
"font-src 'self' data:",
"connect-src 'self' https://*.supabase.co wss://*.supabase.co https://*.r2.cloudflarestorage.com",
"worker-src 'self' blob:",
"object-src 'none'",
"base-uri 'self'",
"form-action 'self'",
"frame-ancestors 'none'",
...(isDevelopment ? [] : ["upgrade-insecure-requests"]),
].join("; ");
const nextConfig: NextConfig = {
poweredByHeader: false,
images: {
remotePatterns: [
{ protocol: "https", hostname: "images.unsplash.com", pathname: "/photo-**" },
...(r2Hostname
? [{ protocol: "https" as const, hostname: r2Hostname, pathname: r2Pathname }]
: []),
],
},
async headers() {
return [
{
source: "/:path*",
headers: [
{ key: "Content-Security-Policy", value: contentSecurityPolicy },
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
{
key: "Permissions-Policy",
value: "camera=(), microphone=(), geolocation=(), payment=(), usb=(), browsing-topics=()",
},
{ key: "Strict-Transport-Security", value: "max-age=31536000; includeSubDomains" },
{ key: "X-Content-Type-Options", value: "nosniff" },
{ key: "X-Frame-Options", value: "DENY" },
{ key: "X-XSS-Protection", value: "0" },
],
},
];
},
};
export default nextConfig;