Files
OpenFlare/frontend/next.config.ts
T
ryan 5a8722ff07 feat(frontend): 控制台 next-intl 中英双语
接入无 URL 前缀的 zh-CN/en,顶栏与外观设置可切换语言;选择写入 cookie 后刷新生效。
2026-08-16 16:49:16 +08:00

54 lines
1.6 KiB
TypeScript

import type { NextConfig } from 'next';
import createNextIntlPlugin from 'next-intl/plugin';
const withNextIntl = createNextIntlPlugin('./i18n/request.ts');
const isExport = process.env.NEXT_STANDALONE_EXPORT === 'true';
const nextConfig: NextConfig = {
reactCompiler: true,
// Prevent 308 redirects on /api/* trailing slashes; dev rewrites proxy legacy APIs as-is.
skipTrailingSlashRedirect: true,
experimental: {
turbopackFileSystemCacheForBuild: true,
},
...(isExport
? { output: 'export' }
: {
async redirects() {
return [
{ source: '/openflare', destination: '/', permanent: true },
{
source: '/openflare/:path*',
destination: '/:path*',
permanent: true,
},
{ source: '/home', destination: '/', permanent: true },
];
},
async rewrites() {
const backendUrl =
process.env.WAVELET_BACKEND_URL || 'http://localhost:3000';
return [
// 上传文件静态资源
{
source: '/f/:id',
destination: `${backendUrl}/f/:id`,
},
// robots.txt 路由代理到后端动态接口
{
source: '/robots.txt',
destination: `${backendUrl}/robots.txt`,
},
// 标准 RESTful API 接口
{
source: '/api/:path*',
destination: `${backendUrl}/api/:path*`,
},
];
},
}),
};
export default withNextIntl(nextConfig);