-
Notifications
You must be signed in to change notification settings - Fork 113
Expand file tree
/
Copy pathnext.config.ts
More file actions
123 lines (110 loc) · 3.5 KB
/
next.config.ts
File metadata and controls
123 lines (110 loc) · 3.5 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
import type { NextConfig } from "next";
import "./src/env";
// Standalone uses symlinks when copying traced deps; Windows often lacks permission (EPERM).
// Use standalone only on non-Windows, or when STANDALONE_BUILD=1 (e.g. CI/Docker or Windows with Developer Mode).
const useStandalone =
process.env.STANDALONE_BUILD === "1" || process.platform !== "win32";
const config: NextConfig = {
// Standalone output for Docker deployment (smaller production image)
output: useStandalone ? "standalone" : undefined,
experimental: {
middlewareClientMaxBodySize: "128mb",
},
// Mermaid loaded client-side at runtime — no need to transpile
// transpilePackages: ["mermaid"],
eslint: { ignoreDuringBuilds: true },
typescript: { ignoreBuildErrors: true },
images: {
remotePatterns: [
{
protocol: "https",
hostname: "iiazjw8b8a.ufs.sh",
port: "",
pathname: "/f/**",
},
],
},
// Exclude unnecessary files from Vercel output (moved from experimental in Next.js 15)
// Apply to all routes using "/*" wildcard
// Disable server-side source maps to reduce build I/O and output size
productionBrowserSourceMaps: false,
// CORS and security headers
async headers() {
const allowedOrigins = process.env.CORS_ALLOWED_ORIGINS?.split(",") ?? [];
return [
{
source: "/api/:path*",
headers: [
{
key: "Access-Control-Allow-Origin",
value: allowedOrigins.length > 0 ? allowedOrigins[0]! : "",
},
{
key: "Access-Control-Allow-Methods",
value: "GET, POST, PUT, PATCH, DELETE, OPTIONS",
},
{
key: "Access-Control-Allow-Headers",
value: "Content-Type, Authorization",
},
{
key: "Access-Control-Max-Age",
value: "86400",
},
],
},
];
},
outputFileTracingExcludes: {
"/*": [
// Exclude onnxruntime-node (transitive dep via @langchain/community → @huggingface/transformers)
"node_modules/.pnpm/onnxruntime-node@*/**",
"node_modules/onnxruntime-node/**",
"**/onnxruntime-node/**",
// Exclude sharp native bindings — loaded as serverExternalPackage
"node_modules/.pnpm/@img+sharp-libvips-linuxmusl-x64@*/**",
"node_modules/.pnpm/@img+sharp-libvips-linux-x64@*/**",
// Exclude pdfjs source maps (keep legacy build — used for Node.js/Inngest)
"node_modules/.pnpm/pdfjs-dist@*/node_modules/pdfjs-dist/build/**/*.map",
],
},
serverExternalPackages: [
// LangChain ecosystem — skip webpack tracing, load from node_modules at runtime
"@langchain/core",
"@langchain/openai",
"@langchain/anthropic",
"@langchain/google-genai",
"@langchain/ollama",
"@langchain/community",
"@langchain/langgraph",
"@langchain/textsplitters",
"langchain",
// AI SDKs
"openai",
// AWS SDK
"@aws-sdk/client-s3",
"@aws-sdk/s3-request-presigner",
// ML
"@huggingface/transformers",
// Document processing
"pdf2pic",
"pdfjs-serverless",
"pdf-lib",
"mammoth",
"jszip",
"readable-stream",
// Native bindings
"sharp",
"@img/sharp-libvips-linuxmusl-x64",
"@img/sharp-libvips-linux-x64",
// Database
"neo4j-driver",
// Transitive deps via @langchain/community — not available on Alpine (musl)
"onnxruntime-node",
"sherpa-onnx-node",
// Structured logging
"pino",
"pino-pretty",
],
};
export default config;