feat(rewrite): support micro frontend

This commit is contained in:
2026-03-10 14:00:24 +08:00
parent ba33231165
commit bef7bd5f31
6 changed files with 45 additions and 5 deletions

View File

@@ -1,5 +1,16 @@
import type { NextConfig } from "next"
const subList: { source: string; url: string }[] = [
{
source: "/image",
url: "http://localhost:5532",
},
{
source: "/video",
url: "http://localhost:5533",
},
]
const nextConfig: NextConfig = {
/* config options here */
basePath: process.env.NEXT_PUBLIC_BASE_PATH,
@@ -7,6 +18,22 @@ const nextConfig: NextConfig = {
| "standalone"
| "export"
| undefined,
async rewrites() {
// 应用代理baseAppProxy
const repoProxy = subList.map(({ source, url }) => {
return {
source,
destination: `${url}${source}`,
}
})
const repoPathProxy = subList.map(({ source, url }) => {
return {
source: `${source}/:path*`,
destination: `${url}${source}/:path*`,
}
})
return [...repoProxy, ...repoPathProxy]
},
}
export default nextConfig