feat(rewrite): support micro frontend
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user