Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nice-windows-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@module-federation/rsbuild-plugin': patch
---

fix(rsbuild-plugin): judge options from orignal userConfig
6 changes: 5 additions & 1 deletion packages/rsbuild-plugin/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,17 @@ export const pluginModuleFederation = (
if (moduleFederationOptions.exposes) {
config.dev ||= {};
config.server ||= {};
const userConfig = api.getRsbuildConfig('original');

// Allow remote modules to be loaded by setting CORS headers
// This is required for MF to work properly across different origins
config.server.headers ||= {};
if (
!config.server.headers['Access-Control-Allow-Origin'] &&
!config.server.cors
!(
typeof userConfig.server?.cors === 'object' &&
userConfig.server.cors.origin
)
) {
const corsWarnMsgs = [
'Detect that CORS options are not set, mf Rsbuild plugin will add default cors header: server.headers["Access-Control-Allow-Headers"] = "*". It is recommended to specify an allowlist of trusted origins in "server.cors" instead.',
Expand Down