-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnext.config.mjs
More file actions
168 lines (157 loc) · 4.19 KB
/
next.config.mjs
File metadata and controls
168 lines (157 loc) · 4.19 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/** @type {import('next').NextConfig} */
const nextConfig = {
// Enable standalone output for better Azure App Service compatibility
output: 'standalone',
// Essential for Azure App Service
serverExternalPackages: ['@tensorflow/tfjs-node'],
poweredByHeader: false,
experimental: {
largePageDataBytes: 128 * 1024 * 1024,
optimizeCss: false,
},
// Configure for Azure App Service
staticPageGenerationTimeout: 1000,
generateEtags: false,
compress: true,
// Disable TypeScript and ESLint checking during build for faster CI
typescript: {
ignoreBuildErrors: true,
tsconfigPath: 'tsconfig.json',
},
eslint: {
ignoreDuringBuilds: true,
},
// Add rewrites for direct file access
async rewrites() {
return [
{
source: '/input_:timestamp_smart_ocr.pdf',
destination: '/api/direct-file/input_:timestamp_smart_ocr.pdf',
},
{
source: '/:filename_:timestamp_smart_ocr.pdf',
destination: '/api/direct-file/:filename_:timestamp_smart_ocr.pdf',
},
{
source: '/:filename_ocr.pdf',
destination: '/api/direct-file/:filename_ocr.pdf',
},
{
source: '/:filename_forced_ocr.pdf',
destination: '/api/direct-file/:filename_forced_ocr.pdf',
}
];
},
async headers() {
return [
{
source: '/:path*',
headers: [
{
key: 'X-DNS-Prefetch-Control',
value: 'on'
},
{
key: 'Strict-Transport-Security',
value: 'max-age=63072000; includeSubDomains; preload'
},
{
key: 'X-XSS-Protection',
value: '1; mode=block'
},
{
key: 'X-Frame-Options',
value: 'SAMEORIGIN'
},
{
key: 'X-Content-Type-Options',
value: 'nosniff'
},
{
key: 'Referrer-Policy',
value: 'origin-when-cross-origin'
},
{
key: 'Permissions-Policy',
value: 'camera=(), microphone=(), geolocation=()'
}
]
}
]
},
webpack: (config, { isServer, dev }) => {
// Improve chunk loading for development and production
if (!isServer) {
config.optimization = {
...config.optimization,
splitChunks: {
chunks: 'all',
maxInitialRequests: 25,
minSize: 20000,
cacheGroups: {
default: false,
vendors: false,
framework: {
chunks: 'all',
name: 'framework',
test: /(?<!node_modules.*)[\\/]node_modules[\\/](react|react-dom|scheduler|next|use-subscription)[\\/]/,
priority: 40,
enforce: true,
reuseExistingChunk: true,
},
lib: {
test: /[\\/]node_modules[\\/]/,
chunks: 'all',
name(module, chunks) {
const moduleFileName = module
.identifier()
.split('/')
.reduceRight((item) => item);
return `npm.${moduleFileName.replace(/(\W|_)/g, '')}`;
},
priority: 30,
minChunks: 1,
reuseExistingChunk: true,
},
},
},
runtimeChunk: { name: 'runtime' },
};
// Disable webpack cache in development to prevent chunk loading issues
config.cache = false;
}
// Fixes npm packages that depend on `fs` module
if (!isServer) {
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
net: false,
tls: false,
child_process: false,
aws4: false,
'aws-sdk': false,
'mock-aws-s3': false,
nock: false,
npm: false,
'node-gyp': false,
long: false,
};
}
// Handle node-pre-gyp HTML file
config.module.rules.push({
test: /\.html$/,
loader: 'raw-loader',
});
return config;
},
eslint: {
ignoreDuringBuilds: true,
},
typescript: {
ignoreBuildErrors: true,
},
images: {
unoptimized: true,
},
}
export default nextConfig;