Files
xingrin/frontend/next.config.ts

40 lines
1.3 KiB
TypeScript
Raw Normal View History

2025-12-12 18:04:57 +08:00
import type { NextConfig } from "next";
2025-12-29 18:09:57 +08:00
import createNextIntlPlugin from 'next-intl/plugin';
const withNextIntl = createNextIntlPlugin('./i18n/request.ts');
2025-12-12 18:04:57 +08:00
// Check if running on Vercel
const isVercel = process.env.VERCEL === '1';
2025-12-12 18:04:57 +08:00
const nextConfig: NextConfig = {
// Use standalone mode for Docker deployment (not needed on Vercel)
...(isVercel ? {} : { output: 'standalone' }),
2025-12-29 18:09:57 +08:00
// Disable Next.js automatic add/remove trailing slash behavior
// Let us manually control URL format
2025-12-12 18:04:57 +08:00
skipTrailingSlashRedirect: true,
2025-12-29 18:09:57 +08:00
// Don't interrupt production build due to ESLint errors (keep lint in dev environment)
2025-12-12 18:04:57 +08:00
eslint: {
ignoreDuringBuilds: true,
},
2025-12-29 18:09:57 +08:00
// Allow LAN IP access to dev server (eliminate CORS warnings)
2025-12-23 20:03:27 +08:00
allowedDevOrigins: ['192.168.*.*', '10.*.*.*', '172.16.*.*'],
2025-12-12 18:04:57 +08:00
async rewrites() {
// Skip rewrites on Vercel when using mock data
if (isVercel) {
return [];
}
2025-12-29 18:09:57 +08:00
// Use server service name in Docker environment, localhost for local development
2025-12-12 18:04:57 +08:00
const apiHost = process.env.API_HOST || 'localhost';
return [
2025-12-29 18:09:57 +08:00
// Only match API paths with trailing slash
2025-12-12 18:04:57 +08:00
{
source: '/api/:path*/',
destination: `http://${apiHost}:8888/api/:path*/`,
},
];
},
};
2025-12-29 18:09:57 +08:00
export default withNextIntl(nextConfig);