-
Notifications
You must be signed in to change notification settings - Fork 7
/
next.config.mjs
89 lines (86 loc) · 2.5 KB
/
next.config.mjs
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
/**
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful
* for Docker builds.
*/
const { env } = await import('./src/env.mjs')
const ContentSecurityPolicy = `
default-src 'none';
base-uri 'self';
font-src 'self' https: data:;
form-action 'self';
frame-ancestors 'self';
img-src 'self' data: blob: ${
// For displaying images from R2
env.R2_PUBLIC_HOSTNAME ? `https://${env.R2_PUBLIC_HOSTNAME}` : ''
};
frame-src 'self';
object-src 'none';
script-src 'self' ${env.NODE_ENV === 'production' ? '' : "'unsafe-eval'"};
style-src 'self' https: 'unsafe-inline';
connect-src 'self' https://browser-intake-datadoghq.com https://*.browser-intake-datadoghq.com https://vitals.vercel-insights.com/v1/vitals ${
// For POSTing presigned URLs to R2 storage.
env.R2_ACCOUNT_ID
? `https://*.${env.R2_ACCOUNT_ID}.r2.cloudflarestorage.com`
: ''
};
worker-src 'self' blob:;
${env.NODE_ENV === 'production' ? 'upgrade-insecure-requests' : ''}
`
/**
* @link https://nextjs.org/docs/api-reference/next.config.js/introduction
*/
/** @type {import("next").NextConfig} */
const config = {
reactStrictMode: true,
/**
* Dynamic configuration available for the browser and server.
* Note: requires `ssr: true` or a `getInitialProps` in `_app.tsx`
* @link https://nextjs.org/docs/api-reference/next.config.js/runtime-configuration
*/
publicRuntimeConfig: {
NODE_ENV: env.NODE_ENV,
},
/** We run eslint as a separate task in CI */
eslint: { ignoreDuringBuilds: !!process.env.CI },
images: {
domains: [env.R2_PUBLIC_HOSTNAME ?? ''].filter((d) => d),
},
async headers() {
return [
{
source: '/(.*)',
headers: [
{
key: 'Content-Security-Policy',
value: ContentSecurityPolicy.replace(/\s{2,}/g, ' ').trim(),
},
{
key: 'Cross-Origin-Opener-Policy',
value: 'same-origin',
},
{
key: 'Cross-Origin-Resource-Policy',
value: 'same-origin',
},
{
key: 'Origin-Agent-Cluster',
value: '?1',
},
{
key: 'Referrer-Policy',
value: 'strict-origin-when-cross-origin',
},
{
key: 'X-Content-Type-Options',
value: 'nosniff',
},
{
key: 'X-Frame-Options',
value: 'SAMEORIGIN',
},
],
},
]
},
}
export default config