Files
mnote/wolai-frontend/next.config.ts
T
2026-01-15 20:54:21 +08:00

40 lines
1.6 KiB
TypeScript
Raw 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";
const nextConfig: NextConfig = {
// 供桌面端打包使用(Electron 内置 Next server.js + 最小依赖)。
// 说明:`pnpm run build:desktop:next` 会依赖该产物。
output: "standalone",
turbopack: {
// 避免 monorepo/多 lockfile 场景下 root 误判,减少构建与热更新的不确定性
root: __dirname,
},
async headers() {
// 说明:ONLYOFFICE 文档服务器会在其 iframe 内跨域拉取插件 manifest/js/html。
// 这里对插件资源放开 CORS,避免 pluginsData 加载失败。
return [
// 说明:远程通过 Cloudflare Tunnel 访问时,Next.jsTurbopack dev)默认对
// `/_next/static/chunks/*` 返回 `no-store`,导致 Cloudflare 无法缓存大体积
// bundle,网络稍慢时会出现页面长期停留在“正在载入编辑器...”的现象。
// 这些资源带 hash 文件名,设置 immutable 不会导致更新不一致。
{
source: "/_next/static/chunks/:path*",
headers: [{ key: "Cache-Control", value: "public, max-age=31536000, immutable" }],
},
{
source: "/_next/static/media/:path*",
headers: [{ key: "Cache-Control", value: "public, max-age=31536000, immutable" }],
},
{
source: "/onlyoffice/plugins/:path*",
headers: [
{ key: "Access-Control-Allow-Origin", value: "*" },
{ key: "Access-Control-Allow-Methods", value: "GET,OPTIONS" },
{ key: "Access-Control-Allow-Headers", value: "*" },
],
},
];
},
};
export default nextConfig;