-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
58 lines (53 loc) · 1.4 KB
/
next.config.js
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
const path = require('path');
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
serverComponentsExternalPackages: ['better-sqlite3'],
},
output: 'standalone',
distDir: '.next',
poweredByHeader: false,
onDemandEntries: {
maxInactiveAge: 25 * 1000,
pagesBufferLength: 2,
},
webpack: (config, { dev, isServer }) => {
// 添加调试日志
console.log('Webpack config:', {
cacheEnabled: !!config.cache,
mode: config.mode,
dev,
isServer,
});
config.resolve.alias = {
...config.resolve.alias,
'@': path.join(__dirname, 'src'),
};
if (!dev) {
config.cache = {
type: 'filesystem',
version: `${process.env.NODE_ENV}-${process.env.npm_package_version}`,
cacheDirectory: path.resolve('.next/cache/webpack'),
store: 'pack',
buildDependencies: {
config: [__filename],
},
};
}
return config;
},
async headers() {
return [
{
source: '/api/:path*',
headers: [
{ key: 'Access-Control-Allow-Credentials', value: 'true' },
{ key: 'Access-Control-Allow-Origin', value: '*' },
{ key: 'Access-Control-Allow-Methods', value: 'GET,POST,OPTIONS,HEAD' },
{ key: 'Access-Control-Allow-Headers', value: 'Content-Type' },
],
},
];
},
};
module.exports = nextConfig;