-
-
Notifications
You must be signed in to change notification settings - Fork 506
Expand file tree
/
Copy pathnext.config.mjs
More file actions
77 lines (72 loc) · 2.76 KB
/
Copy pathnext.config.mjs
File metadata and controls
77 lines (72 loc) · 2.76 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
import createNextIntlPlugin from 'next-intl/plugin'
const withNextIntl = createNextIntlPlugin()
/**
* Undefined entries are not supported. Push optional patterns to this array only if defined.
* @type {import('next/dist/shared/lib/image-config').RemotePattern}
*/
const remotePatterns = []
// S3 Storage
if (process.env.S3_UPLOAD_ENDPOINT) {
// custom endpoint for providers other than AWS
const url = new URL(process.env.S3_UPLOAD_ENDPOINT);
remotePatterns.push({
hostname: url.hostname,
})
} else if (process.env.S3_UPLOAD_BUCKET && process.env.S3_UPLOAD_REGION) {
// default provider
remotePatterns.push({
hostname: `${process.env.S3_UPLOAD_BUCKET}.s3.${process.env.S3_UPLOAD_REGION}.amazonaws.com`,
})
}
/** @type {import('next').NextConfig} */
const nextConfig = {
// Emit a self-contained server into .next/standalone, containing only the
// files Next.js traced as actually reachable at runtime. The Docker runtime
// stage copies that instead of a full production `node_modules`.
output: 'standalone',
images: {
remotePatterns
},
reactCompiler: true,
// Required to run in a codespace (see https://github.com/vercel/next.js/issues/58019)
experimental: {
serverActions: {
// localhost:3000 covers local dev and same-host container access; the
// configured base URL covers a deployment reached under its own domain,
// whose server actions would otherwise be rejected as cross-origin.
// An unparseable value is ignored here rather than thrown: this file is
// evaluated before the env schema runs, and its `Invalid URL` is far less
// useful than the validation error the schema is about to produce.
allowedOrigins: (() => {
const base = process.env.BASE_URL || process.env.NEXT_PUBLIC_BASE_URL
try {
return ['localhost:3000', ...(base ? [new URL(base).host] : [])]
} catch {
return ['localhost:3000']
}
})(),
},
},
async headers() {
return [
{
source: '/:path*',
headers: [
{ key: 'X-Frame-Options', value: 'DENY' },
{ key: 'X-Content-Type-Options', value: 'nosniff' },
{ key: 'Referrer-Policy', value: 'strict-origin-when-cross-origin' },
{
key: 'Permissions-Policy',
value: 'camera=(self), microphone=(), geolocation=()',
},
{
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' https:; frame-ancestors 'none'; base-uri 'self'; form-action 'self'",
},
],
},
]
},
}
export default withNextIntl(nextConfig)