Skip to content

Commit ed072f9

Browse files
authored
fix(rsbuild-plugin): explicitly setting CORS headers (#3635)
1 parent 4b48eb5 commit ed072f9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,12 @@ export const pluginModuleFederation = (
177177
// Change some default configs for remote modules
178178
if (moduleFederationOptions.exposes) {
179179
config.dev ||= {};
180+
config.server ||= {};
181+
182+
// Allow remote modules to be loaded by setting CORS headers
183+
// This is required for MF to work properly across different origins
184+
config.server.headers ||= {};
185+
config.server.headers['Access-Control-Allow-Origin'] ||= '*';
180186

181187
// For remote modules, Rsbuild should send the ws request to the provider's dev server.
182188
// This allows the provider to do HMR when the provider module is loaded in the consumer's page.

0 commit comments

Comments
 (0)