-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathnext.config.mjs
More file actions
114 lines (108 loc) · 2.89 KB
/
next.config.mjs
File metadata and controls
114 lines (108 loc) · 2.89 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
// next.config.mjs
/**
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful
* for Docker builds.
*/
import nextI18NextConfig from './next-i18next.config.mjs'
import withBundleAnalyzer from '@next/bundle-analyzer'
const bundleAnalyzerConfig = {
enabled: process.env.ANALYZE === 'true',
}
/** @type {import("next").NextConfig} */
const config = {
i18n: nextI18NextConfig.i18n,
// Streamdown depends on a set of ESM-only remark/rehype packages; transpiling them
// avoids ERR_REQUIRE_ESM crashes during `/pages` SSR/static generation on Node 18/20.
transpilePackages: [
'streamdown',
'rehype-harden',
'rehype-katex',
'rehype-raw',
'rehype-sanitize',
'remark-cjk-friendly',
'remark-cjk-friendly-gfm-strikethrough',
'remark-gfm',
'remark-math',
'remark-parse',
'remark-rehype',
'unified',
'hast',
'hast-util-to-jsx-runtime',
'unist-util-visit',
'marked',
'mermaid',
'shiki',
'remend',
],
serverRuntimeConfig: {
bodyParser: {
sizeLimit: '100mb',
},
},
webpack(config) {
// Merge existing experiments with the required ones
config.experiments = {
...(config.experiments || {}),
asyncWebAssembly: true,
layers: true, // Enable layers experiment
}
// Adjust the module rules for WASM files
config.module.rules.push({
test: /\.wasm$/,
// Exclude the Next.js middleware WASM loader from processing your WASM files
exclude:
/node_modules\/next\/dist\/build\/webpack\/loaders\/next-middleware-wasm-loader\.js/,
type: 'webassembly/async',
})
return config
},
/**
* If you have `experimental: { appDir: true }` set, then you must comment the below `i18n` config
* out.
*
* @see https://github.com/vercel/next.js/issues/41980
*/
// i18n: {
// locales: ['en'],
// defaultLocale: 'en',
// },
images: {
unoptimized: true,
domains: [
'images.unsplash.com',
'github.com',
'uiuc-chatbot.s3.us-east-1.amazonaws.com',
'images.squarespace-cdn.com',
'raw.githubusercontent.com',
'avatars.githubusercontent.com',
'anthropic.com',
'via.placeholder.com',
],
},
experimental: {
esmExternals: false, // To make certain packages work with the /pages router.
},
async headers() {
return [
{
source: '/api/:path*',
headers: [
{
key: 'Access-Control-Allow-Origin',
value: '*',
},
{
key: 'Access-Control-Allow-Methods',
value: 'GET,PUT,POST,DELETE,OPTIONS',
},
{
key: 'Access-Control-Allow-Headers',
value:
'X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept',
},
],
},
]
},
}
export default withBundleAnalyzer(bundleAnalyzerConfig)(config)