Files
jiang13-bbs/frontend/next.config.ts
freefire ff2ab286fb feat: 书库导入导出/图片变体/书籍搜索/小组件运行时等
新增:
- 书库导入导出(library_import/library_export)及测试
- 图片变体生成(image_variants)与响应式图片(responsiveImage)
- 书籍搜索(bookSearch)+ BookSearch/LibrarySearchGrid 组件
- 小组件运行时(widgetRuntime)与静态检查(widgetLint)
- 上传缓存中间件(upload_cache)与字体 CSS 提取脚本

其它:
- 后端 handlers/services 全量调整
- 前端页面、组件、库函数与配置更新
2026-10-01 03:06:05 +08:00

56 lines
1.7 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { NextConfig } from "next";
// 后端地址:开发可兜底 localhost:3001;生产构建必须显式 BACKEND_URL(禁止静默烤进 localhost)
const isProd = process.env.NODE_ENV === "production";
const API_TARGET =
process.env.BACKEND_URL ||
process.env.NEXT_PUBLIC_API_URL ||
(isProd ? "" : "http://localhost:3001");
if (!API_TARGET) {
throw new Error(
"生产构建必须设置 BACKEND_URL(例如 Docker 内 http://api:3001),禁止回落 localhost"
);
}
const nextConfig: NextConfig = {
// 官方 Docker 运行时:最小产物,不含完整 node_modules。next dev 忽略此项。
output: "standalone",
images: {
minimumCacheTTL: 14400, // 4 小时
remotePatterns: [
{ protocol: "http", hostname: "localhost" },
],
},
experimental: {
// rewrite/proxy 默认只缓冲 10MB;附件上限由 Go 站点设置决定,此处留足余量(含 multipart 开销)
proxyClientMaxBodySize: "512mb",
},
async rewrites() {
return [
{
source: "/api/:path*",
destination: `${API_TARGET}/api/:path*`,
},
// 用户上传文件(头像等,全部 WebP)
{
source: "/uploads/:path*",
destination: `${API_TARGET}/uploads/:path*`,
},
];
},
async headers() {
return [
{
// 构建后抽取的 Noto Sans SC 字体声明(异步加载,见 scripts/extract-font-css.mjs)。
// 引用的 woff2 在 /_next/static/media/ 已 immutable;CSS 本身文件名固定、内容随
// 字体版本变,用 1 天中等 TTL 稳妥。
source: "/fonts/:path*",
headers: [{ key: "Cache-Control", value: "public, max-age=86400" }],
},
];
},
};
export default nextConfig;