89 lines
1.6 KiB
TypeScript
89 lines
1.6 KiB
TypeScript
import type { NextConfig } from "next";
|
|
|
|
const nextConfig: NextConfig = {
|
|
// 启用 standalone 输出模式(用于 Docker 部署)
|
|
output: "standalone",
|
|
|
|
// 实验性功能
|
|
experimental: {
|
|
// 启用服务器组件
|
|
serverActions: {
|
|
bodySizeLimit: "10mb",
|
|
},
|
|
},
|
|
|
|
// 图片优化配置
|
|
images: {
|
|
// 允许的图片域名
|
|
remotePatterns: [
|
|
{
|
|
protocol: "https",
|
|
hostname: "**",
|
|
},
|
|
],
|
|
// 图片格式
|
|
formats: ["image/avif", "image/webp"],
|
|
},
|
|
|
|
// 压缩配置
|
|
compress: true,
|
|
|
|
// 严格模式
|
|
reactStrictMode: true,
|
|
|
|
// 环境变量
|
|
env: {
|
|
BLOG_ROOT: process.env.BLOG_ROOT || "",
|
|
},
|
|
|
|
// Webpack 配置
|
|
webpack: (config, { isServer }) => {
|
|
// 修复某些依赖的兼容性问题
|
|
if (!isServer) {
|
|
config.resolve.fallback = {
|
|
...config.resolve.fallback,
|
|
fs: false,
|
|
net: false,
|
|
tls: false,
|
|
};
|
|
}
|
|
return config;
|
|
},
|
|
|
|
// 重写规则(可选)
|
|
async rewrites() {
|
|
return [
|
|
// API 代理(如果需要)
|
|
// {
|
|
// source: '/api/:path*',
|
|
// destination: 'http://backend:3000/api/:path*',
|
|
// },
|
|
];
|
|
},
|
|
|
|
// 头部配置
|
|
async headers() {
|
|
return [
|
|
{
|
|
source: "/(.*)",
|
|
headers: [
|
|
{
|
|
key: "X-Frame-Options",
|
|
value: "SAMEORIGIN",
|
|
},
|
|
{
|
|
key: "X-Content-Type-Options",
|
|
value: "nosniff",
|
|
},
|
|
{
|
|
key: "X-XSS-Protection",
|
|
value: "1; mode=block",
|
|
},
|
|
],
|
|
},
|
|
];
|
|
},
|
|
};
|
|
|
|
export default nextConfig;
|