-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathnext.config.mjs
More file actions
141 lines (133 loc) · 3.63 KB
/
next.config.mjs
File metadata and controls
141 lines (133 loc) · 3.63 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// NOTE: related to src/configs/rewrites.ts
import path from 'node:path'
export const DOCUMENTATION_DOMAIN = 'e2b.mintlify.app'
const browserStub = (file) => 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'),
}
/** @type {import('next').NextConfig} */
const config = {
reactStrictMode: true,
reactCompiler: true,
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) => {
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',
},
],
},
],
rewrites: async () => ({
beforeFiles: [
{
source: '/ph-proxy/static/:path*',
destination: 'https://us-assets.i.posthog.com/static/:path*',
},
{
source: '/ph-proxy/:path*',
destination: 'https://us.i.posthog.com/:path*',
},
// Asset rewrites for Mintlify
{
source: '/mintlify-assets/:path*',
destination: `https://${DOCUMENTATION_DOMAIN}/mintlify-assets/:path*`,
},
{
source: '/_mintlify/:path*',
destination: `https://${DOCUMENTATION_DOMAIN}/_mintlify/:path*`,
},
// LLMs.txt
{
source: '/llms.txt',
destination: `https://${DOCUMENTATION_DOMAIN}/llms.txt`,
},
{
source: '/llms-full.txt',
destination: `https://${DOCUMENTATION_DOMAIN}/llms-full.txt`,
},
],
}),
redirects: async () => [
{
source: '/docs/api/cli',
destination: '/auth/cli',
permanent: true,
},
{
source: '/auth/sign-in',
destination: '/sign-in',
permanent: true,
},
{
source: '/auth/sign-up',
destination: '/sign-up',
permanent: true,
},
// SEO Redirects
{
source: '/ai-agents/:path*',
destination: '/',
permanent: true,
},
{
source:
'/blog/how-perplexity-implemented-advanced-data-analysis-for-pro-users-in-1-week',
destination: '/blog/category/case-studies',
permanent: true,
},
],
skipTrailingSlashRedirect: true,
}
export default config