module-federation-examples icon indicating copy to clipboard operation
module-federation-examples copied to clipboard

fix(routing): not found main.js & remoteEntry.js

Open barsheshet opened this issue 3 years ago • 1 comments

If landing on a "deep" route path like /profile/foo/bar, main.js and remoteEntry.js assets are not found. The problem is that script tags src in the HTML are not absolute (main.js instead of /main.js).

This can be solved by either:

  • change publicPath from auto to a "hard-coded" URL (ie. http://localhost:3001/).
  • use HashRouter.

Is there any better solution? Yes! change publicPath in html-webpack-plugin to be /. This works just fine for me.

I know, it might be a problem with how html-webpack-plugin treat auto. Until we find out if it is, and create a PR, this is not a bad workaround :)

barsheshet avatar Aug 04 '22 06:08 barsheshet

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Aug 04 '22 06:08 CLAassistant