Initial commit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
谢宇宁
2026-11-05 22:26:18 +07:00
co-authored by Claude Opus 5.5
commit 6fb2b1e486
385 changed files with 48049 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
import type { NextConfig } from "next";
/** 构建期兜底代理。请求期以 API_PROXY_TARGET 为准,见 src/lib/api/upstream-proxy.ts。 */
const apiProxyTarget = (process.env.API_PROXY_TARGET || "").replace(/\/$/, "");
const appEnv = process.env.APP_ENV;
const nextConfig: NextConfig = {
output: "standalone",
// 仅在显式 APP_ENV=test|development 时分目录;未设置 / production 仍用 .next
distDir:
appEnv === "test" ? ".next-test" : appEnv === "development" ? ".next-dev" : ".next",
poweredByHeader: false,
cacheComponents: true,
partialPrefetching: true,
// 本机用 127.0.0.1 打开时,允许跨源访问 Next 开发资源
allowedDevOrigins: ["127.0.0.1"],
turbopack: {
rules: {
"*.css": {
loaders: ["@tailwindcss/turbopack"],
as: "*.css",
},
},
},
async rewrites() {
if (!apiProxyTarget) return [];
// fallback:动态 Route Handler(upstream-proxy)优先;避免 afterFiles 抢走
// /api/[...path] 后走 Next httpxy(本机 IPv6 不通时 AggregateError → 500)。
// /h5/m3u8、/enkey、/newenkey 由 route handler(lib/media/proxy)代理,密钥地址不带尾斜杠
const proxy = [
{
source: "/api/:path*",
destination: `${apiProxyTarget}/api/:path*`,
},
];
return { fallback: proxy };
},
};
export default nextConfig;