Skip to content

Commit

Permalink
chore: no replace ipv4 in runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
2heal1 committed Jul 25, 2024
1 parent 93f96a3 commit 31b6891
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/modernjs/src/cli/configPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export const moduleFederationConfigPlugin = (
},
define: {
FEDERATION_IPV4: JSON.stringify(ipv4),
REMOTE_IP_STRATEGY: JSON.stringify(userConfig.remoteIpStrategy),
},
},
dev: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@ import type { FederationRuntimePlugin } from '@module-federation/enhanced/runtim
import { LOCALHOST } from '../../constant';

declare const FEDERATION_IPV4: string | undefined;
declare const REMOTE_IP_STRATEGY: 'ipv4' | 'inherit' | undefined;

const ipv4 =
typeof FEDERATION_IPV4 !== 'undefined' ? FEDERATION_IPV4 : '127.0.0.1';

const remoteIpStrategy =
typeof REMOTE_IP_STRATEGY !== 'undefined' ? REMOTE_IP_STRATEGY : '127.0.0.1';

function replaceObjectLocalhost(key: string, obj: Record<string, any>) {
if (remoteIpStrategy !== 'ipv4') {
return;
}
if (!(key in obj)) {
return;
}
Expand Down

0 comments on commit 31b6891

Please sign in to comment.