-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathnext.config.ts
More file actions
70 lines (66 loc) · 2.16 KB
/
next.config.ts
File metadata and controls
70 lines (66 loc) · 2.16 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
import type { NextConfig } from "next";
const isStaticBuild = process.env.ROUTA_BUILD_STATIC === "1";
const isDesktopServerBuild = process.env.ROUTA_DESKTOP_SERVER_BUILD === "1";
const isDesktopStandaloneBuild = process.env.ROUTA_DESKTOP_STANDALONE === "1";
// When set, proxy API requests to the Rust backend server (desktop mode without Node.js backend)
const rustBackendUrl = process.env.ROUTA_RUST_BACKEND_URL;
const nextConfig: NextConfig = {
typescript: {
tsconfigPath: isDesktopServerBuild ? "tsconfig.desktop.json" : "tsconfig.json",
},
serverExternalPackages: [
"@modelcontextprotocol/sdk",
"@agentclientprotocol/sdk",
"@anthropic-ai/claude-agent-sdk",
"ws",
"bufferutil",
"utf-8-validate",
"better-sqlite3",
],
// Ensure cli.js (Claude Code agent binary) is included in Vercel's deployment
// bundle. It's not statically imported so file-tracing won't pick it up
// automatically; this forces Vercel to copy the whole SDK package.
outputFileTracingIncludes: {
"/api/**": [
"./node_modules/@anthropic-ai/claude-agent-sdk/**/*",
// Include skill definitions so Claude Code SDK can discover them on Vercel
"./.claude/skills/**/*",
"./.agents/skills/**/*",
],
},
...(isDesktopServerBuild ? { distDir: ".next-desktop" } : {}),
...(isDesktopStandaloneBuild
? {
output: "standalone",
outputFileTracingIncludes: {
"/api/**": ["./node_modules/@anthropic-ai/claude-agent-sdk/**/*"],
"/*": ["./node_modules/better-sqlite3/**/*"],
},
}
: {}),
...(isStaticBuild
? {
output: "export",
images: { unoptimized: true },
}
: {}),
// Proxy /api/* to Rust backend when ROUTA_RUST_BACKEND_URL is set.
// Uses beforeFiles to override local Next.js API routes.
...(rustBackendUrl
? {
async rewrites() {
return {
beforeFiles: [
{
source: "/api/:path*",
destination: `${rustBackendUrl}/api/:path*`,
},
],
afterFiles: [],
fallback: [],
};
},
}
: {}),
};
export default nextConfig;