Skip to content

Commit d237ab9

Browse files
authored
fix(rsbuild-plugin): judge options from orignal userConfig (#3757)
1 parent 26f8a77 commit d237ab9

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

.changeset/nice-windows-stare.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/rsbuild-plugin': patch
3+
---
4+
5+
fix(rsbuild-plugin): judge options from orignal userConfig

packages/rsbuild-plugin/src/cli/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,17 @@ export const pluginModuleFederation = (
178178
if (moduleFederationOptions.exposes) {
179179
config.dev ||= {};
180180
config.server ||= {};
181+
const userConfig = api.getRsbuildConfig('original');
181182

182183
// Allow remote modules to be loaded by setting CORS headers
183184
// This is required for MF to work properly across different origins
184185
config.server.headers ||= {};
185186
if (
186187
!config.server.headers['Access-Control-Allow-Origin'] &&
187-
!config.server.cors
188+
!(
189+
typeof userConfig.server?.cors === 'object' &&
190+
userConfig.server.cors.origin
191+
)
188192
) {
189193
const corsWarnMsgs = [
190194
'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.',

0 commit comments

Comments
 (0)