Skip to content

Commit

Permalink
(fix: react): full support custom secure host for module federation
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadim Goy committed Feb 12, 2024
1 parent dbd0e7b commit 2ab6931
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ async function startDevRemotes(
staticRemotes: string[];
devRemotes: string[];
},
context: ExecutorContext
context: ExecutorContext,
options: ModuleFederationDevServerOptions
) {
const devRemoteIters: AsyncIterable<{ success: boolean }>[] = [];

Expand All @@ -119,6 +120,10 @@ async function startDevRemotes(
},
{
watch: true,
host: options.host,
ssl: options.ssl,
sslCert: options.sslCert,
sslKey: options.sslKey,
...(isUsingModuleFederationDevServerExecutor
? { isInitialHost: false }
: {}),
Expand Down Expand Up @@ -291,7 +296,7 @@ export default async function* moduleFederationDevServer(
);
await buildStaticRemotes(staticRemotesConfig, nxBin, context, options);

const devRemoteIters = await startDevRemotes(remotes, context);
const devRemoteIters = await startDevRemotes(remotes, context, options);

const staticRemotesIter =
remotes.staticRemotes.length > 0
Expand Down Expand Up @@ -321,15 +326,16 @@ export default async function* moduleFederationDevServer(
waitForPortOpen(port, {
retries: 480,
retryDelay: 2500,
host: 'localhost',
host: options.host ?? 'localhost',
})
)
);

logger.info(
`NX All remotes started, server ready at http://localhost:${options.port}`
);
next({ success: true, baseUrl: `http://localhost:${options.port}` });
const baseUrl = `http${options.ssl ? 's' : ''}://${options.host}:${
options.port
}`;
logger.info(`NX All remotes started, server ready at ${baseUrl}`);
next({ success: true, baseUrl: baseUrl });
} catch {
throw new Error(
`Timed out waiting for remote to start. Check above for any errors.`
Expand Down

0 comments on commit 2ab6931

Please sign in to comment.