Repository navigation
Expand file tree
/
Copy pathnext.config.ts
More file actions
85 lines (79 loc) · 2.39 KB
/
Copy pathnext.config.ts
File metadata and controls
85 lines (79 loc) · 2.39 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
import path from 'node:path'
import type { NextConfig } from 'next'
const browserStub = (file: string) => path.resolve(process.cwd(), 'stubs', file)
const browserNodeModuleStubs = {
crypto: browserStub('crypto.ts'),
fs: browserStub('fs.ts'),
'fs/promises': browserStub('fs-promises.ts'),
path: browserStub('path.ts'),
'node:crypto': browserStub('crypto.ts'),
'node:fs': browserStub('fs.ts'),
'node:fs/promises': browserStub('fs-promises.ts'),
'node:path': browserStub('path.ts'),
}
const config: NextConfig = {
reactStrictMode: true,
reactCompiler: true,
// Emits .next/standalone: a server plus only the traced dependencies, which
// is what the container image runs. `next start` still works from .next for
// local previews, and platform builds ignore this output.
output: 'standalone',
experimental: {
useCache: true,
turbopackFileSystemCacheForDev: true,
serverActions: {
bodySizeLimit: '5mb',
},
authInterrupts: true,
},
turbopack: {
resolveAlias: {
crypto: { browser: './stubs/crypto.ts' },
fs: { browser: './stubs/fs.ts' },
'fs/promises': { browser: './stubs/fs-promises.ts' },
path: { browser: './stubs/path.ts' },
'node:crypto': { browser: './stubs/crypto.ts' },
'node:fs': { browser: './stubs/fs.ts' },
'node:fs/promises': { browser: './stubs/fs-promises.ts' },
'node:path': { browser: './stubs/path.ts' },
},
},
webpack: (webpackConfig, { isServer, webpack }) => {
if (!isServer) {
webpackConfig.resolve.alias = {
...webpackConfig.resolve.alias,
...browserNodeModuleStubs,
}
webpackConfig.plugins.push(
new webpack.NormalModuleReplacementPlugin(
/^node:/,
(resource: { request: string }) => {
resource.request = resource.request.replace(/^node:/, '')
}
)
)
}
return webpackConfig
},
logging: {
fetches: {
fullUrl: true,
},
},
serverExternalPackages: ['pino'],
trailingSlash: false,
headers: async () => [
{
source: '/(.*)',
headers: [
{
// config to prevent the browser from rendering the page inside a frame or iframe and avoid clickjacking http://en.wikipedia.org/wiki/Clickjacking
key: 'X-Frame-Options',
value: 'SAMEORIGIN',
},
],
},
],
skipTrailingSlashRedirect: true,
}
export default config