ef9e87fb29
- 移除自定义createId函数,统一使用nanoid库生成唯一标识符 - 将useEffectiveAiConfig Hook替换为resolveEffectiveConfig工具函数 - 直接从config store获取publicSettings避免额外的Hook依赖 - 更新所有组件中的ID生成调用以使用nanoid - 简化buildApiUrl函数中的基础URL规范化逻辑
33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import type { NextConfig } from "next";
|
|
import { PHASE_DEVELOPMENT_SERVER } from "next/constants";
|
|
import { loadEnvConfig } from "@next/env";
|
|
import { readFileSync } from "node:fs";
|
|
import { fileURLToPath } from "node:url";
|
|
import { dirname, resolve } from "node:path";
|
|
import { parseChangelog } from "@/lib/release";
|
|
|
|
const webDir = dirname(fileURLToPath(import.meta.url));
|
|
const localVersion = readFileSync(resolve(webDir, "../VERSION"), "utf8").trim() || "dev";
|
|
const localChangelog = readFileSync(resolve(webDir, "../CHANGELOG.md"), "utf8");
|
|
|
|
export default function nextConfig(phase: string): NextConfig {
|
|
const isDev = phase === PHASE_DEVELOPMENT_SERVER;
|
|
loadEnvConfig(resolve(webDir, ".."), isDev, undefined, true);
|
|
const apiBaseUrl = process.env.API_BASE_URL || "http://127.0.0.1:8080";
|
|
const releases = parseChangelog(localChangelog);
|
|
|
|
return {
|
|
allowedDevOrigins: isDev ? ["*.*.*.*"] : [],
|
|
typescript: {
|
|
ignoreBuildErrors: true,
|
|
},
|
|
env: {
|
|
NEXT_PUBLIC_APP_VERSION: localVersion,
|
|
NEXT_PUBLIC_APP_RELEASES: JSON.stringify(releases),
|
|
},
|
|
async rewrites() {
|
|
return [{ source: "/api/:path*", destination: `${apiBaseUrl}/api/:path*` }];
|
|
},
|
|
};
|
|
}
|