Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mfe remote not accessible on client with docker (works locally) #29717

Open
1 of 4 tasks
Barrier-Theo opened this issue Jan 22, 2025 · 1 comment
Open
1 of 4 tasks

Mfe remote not accessible on client with docker (works locally) #29717

Barrier-Theo opened this issue Jan 22, 2025 · 1 comment
Assignees
Labels
scope: module federation Issues related to module federation support type: bug

Comments

@Barrier-Theo
Copy link

Barrier-Theo commented Jan 22, 2025

Current Behavior

Hi everyone,

I am working on a host project that loads five remote modules with Nx and Angular. After upgrading Nx to version 20.3.1 and Angular to version 19.0.7, everything builds successfully, and there are no build errors. However, when I attempt to access three of the remotes via their respective links, I encounter an issue where they do not load, whereas the other two remotes work fine.

Client-side Issue: When I click the link to load a remote, I receive a 404 Not Found error. Interestingly, if I manually click on the link in the browser, it works, and I can access the resource.

Image

Verbose Log Output: When I run the command with --verbose, I see the following log entry:

2025-01-22 15:51:21 [webpack-dev-server] [connect-history-api-fallback] Not rewriting GET /remoteEntry.mjs because the client does not accept HTML.

Docker Setup: I am using Docker to build the project where the issue occurs. However, when I install the dependencies manually and start the project with the following script:

scripts": {
    "start:local": "node --max_old_space_size=8192 ./node_modules/nx/bin/nx serve shell --devRemotes=admin,campaigner,loader,planner,production,viewer --disable-host-check --open",
},

everything works as expected, and I can click and load all remotes successfully.

Here the configuration of one remote in admin/project.json:

"serve": {
     "executor": "@nx/angular:dev-server",
     "options": {
       "port": 4201,
       "ssl": true,
       "sslKey": "./ssl/app_dev.key",
       "sslCert": "./ssl/app_dev.crt",
       "publicHost": "https://app-dev.fideliste.com:4201",
       "host": "0.0.0.0"
     },

in admin/module-federation.config.ts

const config: ModuleFederationConfig = {
  name: 'admin',
  exposes: {
    './Routes': 'apps/admin/src/app/remote-entry/entry.routes.ts',
  },
};

export default config;

in admin/webpack.config.ts

import { withModuleFederation } from '@nx/module-federation/angular';
import config from './module-federation.config';

/**
 * DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
 * The DTS Plugin can be enabled by setting dts: true
 * Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
 */
export default withModuleFederation(
  {
    ...config,
    /*
     * Remote overrides for production.
     * Each entry is a pair of a unique name and the URL where it is deployed.
     *
     * e.g.
     * remotes: [
     *   ['app1', 'https://app1.example.com'],
     *   ['app2', 'https://app2.example.com'],
     * ]
     */
  },
  { dts: false },
);

and then define the route like this:

{
    path: AppRoutesEnum.ADMIN,
    loadChildren: () => loadRemoteModule(ModulesEnum.ADMIN, './Routes').then((m) => m.remoteRoutes),
    canActivate: [RoleGuard],
    data: { roles: [UserRolesEnum.ADMIN] },
},

I am aware that loadRemoteModule is deprecated, but I have not yet found a suitable replacement with the new API.

I also found a simular topic: #28479 but it seems it has been close due to the lack of activity.

I tried also load all the modules independantly, and also all without one (production) one and it seems it works too with docker. So it seems that production remote is the problem, but the configuration is the same are all others...

Any insights, suggestions, or questions are welcome. I am quite perplexed by this issue and would greatly appreciate any help or guidance.

Thank you in advance!

Expected Behavior

It should be able to click on all remotes and load succesfully the remote with docker

GitHub Repo

No response

Steps to Reproduce

.

Nx Report

Your repository uses a higher version of Nx (20.3.1) than your global CLI version (19.4.4)
For more information, see https://nx.dev/more-concepts/global-nx

Failure Logs

fid_dev_front     |     [webpack-dev-server] [connect-history-api-fallback] Not rewriting GET /remoteEntry.mjs because the client does not accept HTML.


Also 404 Not Found on https://app-dev.fideliste.com:4201/remoteEntry.mjs

Package Manager Version

10.9.2

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@yarommax
Copy link

I have the same issue

@AgentEnder AgentEnder added the scope: module federation Issues related to module federation support label Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: module federation Issues related to module federation support type: bug
Projects
None yet
Development

No branches or pull requests

4 participants