更新 .env.example,提供更清晰的 API 配置说明与本地开发环境配置指引。 修改 next.config.ts:支持动态解析允许的开发环境来源(origins),提升配置灵活性。 重构 admin-language-switcher:优化语言切换同步机制,确保语言变更能够及时生效。 优化英文、尼泊尔语与中文语言包中的错误提示文案,进一步明确 API 配置要求。 精简 admin-http.ts:将 API Base URL 校验逻辑抽离至独立模块并统一导出,提升代码可维护性。
37 lines
874 B
TypeScript
37 lines
874 B
TypeScript
import type { NextConfig } from "next";
|
|
|
|
import { parseAllowedDevOrigins } from "./src/lib/next-dev-origins";
|
|
|
|
const apiBaseUrl = process.env.API_BASE_URL?.trim() || "http://127.0.0.1:8000";
|
|
const allowedDevOrigins = parseAllowedDevOrigins(process.env.ALLOWED_DEV_ORIGINS);
|
|
|
|
const nextConfig: NextConfig = {
|
|
/* config options here */
|
|
...(allowedDevOrigins.length > 0 ? { allowedDevOrigins } : {}),
|
|
reactCompiler: true,
|
|
async rewrites() {
|
|
return [
|
|
{
|
|
source: "/api/:path*",
|
|
destination: `${apiBaseUrl}/api/:path*`,
|
|
},
|
|
];
|
|
},
|
|
async redirects() {
|
|
return [
|
|
{
|
|
source: "/admin/service-desk",
|
|
destination: "/admin",
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: "/admin/menu-permissions",
|
|
destination: "/admin",
|
|
permanent: true,
|
|
},
|
|
];
|
|
},
|
|
};
|
|
|
|
export default nextConfig;
|