diff --git a/next.config.mjs b/next.config.mjs index c37e2e6f..ceddf3d4 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -1,12 +1,12 @@ // next.config.mjs /** @type {import('next').NextConfig} */ import nextI18nextConfig from "./next-i18next.config.js"; -import { NextFederationPlugin } from '@module-federation/nextjs-mf'; -const url = process.env.NEXT_PUBLIC_REMOTE_EDITOR_URL - +import { NextFederationPlugin } from "@module-federation/nextjs-mf"; +const url = process.env.WORKSPACE_BASE_URL; +// const url = "http://localhost:3000"; const remotes = (isServer) => { - const location = isServer ? 'ssr' : 'chunks'; + const location = isServer ? "ssr" : "chunks"; return { editor: `editor@${url}/_next/static/${location}/remoteEntry.js`, }; @@ -21,7 +21,7 @@ const nextConfig = { reactStrictMode: true, i18n: nextI18nextConfig.i18n, - distDir: 'build', + distDir: "build", images: { unoptimized: true, }, @@ -30,27 +30,36 @@ const nextConfig = { esmExternals: false, }, async rewrites() { - return [ + return [ + { + source: "/action/asset/v1/upload/:identifier*", // Match asset upload routes + destination: `${process.env.WORKSPACE_BASE_URL}/api/fileUpload`, // Forward asset uploads to fileUpload.js + }, + { + source: "/action/asset/:path*", // Match other /action/asset routes + destination: `${process.env.WORKSPACE_BASE_URL}/api/proxy?path=/action/asset/:path*`, // Forward other /action/asset requests to proxy.js + }, { - source: '/action/:path*', - destination: '/api/proxy?path=/action/:path*', + source: "/action/:path*", // Match any other routes starting with /action/ + destination: `${process.env.WORKSPACE_BASE_URL}/api/proxy?path=/action/:path*`, // Forward them to proxy.js }, { - source: '/api/:path*', - destination: '/api/proxy?path=/api/:path*', - } + source: "/api/:path*", // Match /api/ routes + destination: `${process.env.WORKSPACE_BASE_URL}/api/proxy?path=/api/:path*`, // Forward them to proxy.js + }, + { + source: "/assets/public/:path*", // Match any URL starting with /assets/public/ + destination: `${process.env.CLOUD_STORAGE_URL}/:path*`, // Forward to S3, stripping "/assets/public" + }, ]; }, webpack: (config, { isServer }) => { config.plugins.push( new NextFederationPlugin({ - name: 'admin', - filename: 'static/chunks/remoteEntry.js', + name: "admin", + filename: "static/chunks/remoteEntry.js", remotes: remotes(isServer), - exposes: { - - }, - + exposes: {}, }) ); return config;