Files
Edu/apps/admin-portal/next.config.js
SpecialX 64b2016fa8 feat(admin-portal): docker 本地测试通过 + 下游工作清单
docker Desktop 本地验证:
- 镜像构建成功(edu/admin-portal:test)
- 容器运行正常(端口 4003)
- /api/health、/api/ready、/login、/admin/dashboard 全部 200

修复项:
- next.config.js 添加 output: standalone
- package.json 添加 autoprefixer 依赖
- login/layout.tsx 提供 AuthProvider/ToastProvider

部署配置:
- docker-compose.deploy.yml 添加 admin-portal 服务
- deploy.env.example 添加 ADMIN_PORTAL_PORT

下游工作清单(nextstep.md):
- api-gateway: 缺 /api/admin/graphql 路由
- teacher-bff: 缺 16 Query + 11 Mutation
- iam: 缺 BatchGetUsers 等 RPC
2026-07-13 16:19:35 +08:00

55 lines
1.6 KiB
JavaScript

const NextFederationPlugin = require("@module-federation/nextjs-mf");
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
output: "standalone",
transpilePackages: [
"@edu/ui-tokens",
"@edu/ui-components",
"@edu/hooks",
],
async rewrites() {
const gatewayUrl = process.env.API_GATEWAY_URL || "http://localhost:8080";
return [
{
source: "/api/admin/graphql",
destination: `${gatewayUrl}/api/admin/graphql`,
},
{
source: "/api/:path*",
destination: `${gatewayUrl}/api/:path*`,
},
];
},
webpack(config, { isServer }) {
if (process.env.NEXT_PUBLIC_MF_ENABLED === "true") {
config.plugins.push(
new NextFederationPlugin({
name: "admin_app",
filename: "static/chunks/remoteEntry.js",
exposes: {
"./AdminApp": "./src/app/admin-app.tsx",
},
remotes: {
teacher: `teacher_app@http://localhost:4000/_next/static/${isServer ? "ssr" : "chunks"}/remoteEntry.js`,
},
shared: {
react: { singleton: true, requiredVersion: "^18.3.0" },
"react-dom": { singleton: true, requiredVersion: "^18.3.0" },
urql: { singleton: true },
graphql: { singleton: true },
"@edu/ui-tokens": { singleton: true },
"@edu/ui-components": { singleton: true },
"@edu/hooks": { singleton: true },
},
extraOptions: { exposePages: false },
}),
);
}
return config;
},
};
module.exports = nextConfig;