forked from u14app/deep-research
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.ts
123 lines (119 loc) · 3.86 KB
/
next.config.ts
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
import type { NextConfig } from "next";
import pkg from "./package.json";
const BUILD_MODE = process.env.NEXT_PUBLIC_BUILD_MODE;
// AI provider API base url
const API_PROXY_BASE_URL = process.env.API_PROXY_BASE_URL || "";
const GOOGLE_GENERATIVE_AI_API_BASE_URL =
process.env.GOOGLE_GENERATIVE_AI_API_BASE_URL ||
"https://generativelanguage.googleapis.com";
const OPENROUTER_API_BASE_URL =
process.env.OPENROUTER_API_BASE_URL || "https://openrouter.ai/api";
const OPENAI_API_BASE_URL =
process.env.OPENAI_API_BASE_URL || "https://api.openai.com";
const ANTHROPIC_API_BASE_URL =
process.env.ANTHROPIC_API_BASE_URL || "https://api.anthropic.com";
const DEEPSEEK_API_BASE_URL =
process.env.DEEPSEEK_API_BASE_URL || "https://api.deepseek.com";
const XAI_API_BASE_URL = process.env.XAI_API_BASE_URL || "https://api.x.ai";
const OLLAMA_API_BASE_URL =
process.env.OLLAMA_API_BASE_URL || "http://0.0.0.0:11434";
const OPENAI_COMPATIBLE_API_BASE_URL =
process.env.OPENAI_COMPATIBLE_API_BASE_URL || "";
// Search provider API base url
const TAVILY_API_BASE_URL =
process.env.TAVILY_API_BASE_URL || "https://api.tavily.com";
const FIRECRAWL_API_BASE_URL =
process.env.FIRECRAWL_API_BASE_URL || "https://api.firecrawl.dev";
const EXA_API_BASE_URL = process.env.EXA_API_BASE_URL || "https://api.exa.ai";
const BOCHA_API_BASE_URL =
process.env.BOCHA_API_BASE_URL || "https://api.bochaai.com";
const SEARXNG_API_BASE_URL =
process.env.SEARXNG_API_BASE_URL || "http://0.0.0.0:8080";
const nextConfig: NextConfig = {
/* config options here */
experimental: {
reactCompiler: true,
},
env: {
NEXT_PUBLIC_VERSION: pkg.version,
},
};
if (BUILD_MODE === "export") {
nextConfig.output = "export";
// Only used for static deployment, the default deployment directory is the root directory
nextConfig.basePath = "";
// Statically exporting a Next.js application via `next export` disables API routes and middleware.
nextConfig.webpack = (config) => {
config.module.rules.push({
test: /src\/app\/api/,
loader: "ignore-loader",
});
config.module.rules.push({
test: /src\/middleware/,
loader: "ignore-loader",
});
return config;
};
} else if (BUILD_MODE === "standalone") {
nextConfig.output = "standalone";
} else {
nextConfig.rewrites = async () => {
return [
{
source: "/api/ai/google/:path*",
destination: `${
GOOGLE_GENERATIVE_AI_API_BASE_URL || API_PROXY_BASE_URL
}/:path*`,
},
{
source: "/api/ai/openrouter/:path*",
destination: `${OPENROUTER_API_BASE_URL}/:path*`,
},
{
source: "/api/ai/openai/:path*",
destination: `${OPENAI_API_BASE_URL}/:path*`,
},
{
source: "/api/ai/anthropic/:path*",
destination: `${ANTHROPIC_API_BASE_URL}/:path*`,
},
{
source: "/api/ai/deepseek/:path*",
destination: `${DEEPSEEK_API_BASE_URL}/:path*`,
},
{
source: "/api/ai/xai/:path*",
destination: `${XAI_API_BASE_URL}/:path*`,
},
{
source: "/api/ai/openaicompatible/:path*",
destination: `${OPENAI_COMPATIBLE_API_BASE_URL}/:path*`,
},
{
source: "/api/ai/ollama/:path*",
destination: `${OLLAMA_API_BASE_URL}/:path*`,
},
{
source: "/api/search/tavily/:path*",
destination: `${TAVILY_API_BASE_URL}/:path*`,
},
{
source: "/api/search/firecrawl/:path*",
destination: `${FIRECRAWL_API_BASE_URL}/:path*`,
},
{
source: "/api/search/exa/:path*",
destination: `${EXA_API_BASE_URL}/:path*`,
},
{
source: "/api/search/bocha/:path*",
destination: `${BOCHA_API_BASE_URL}/:path*`,
},
{
source: "/api/search/searxng/:path*",
destination: `${SEARXNG_API_BASE_URL}/:path*`,
},
];
};
}
export default nextConfig;