-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[React - Module Federation setup] baseHref only applies to "serve" target but not "serve-static" target #10310
Comments
Hey! thanks for reporting this! The best approach to this is to/wait for a PR on Currently, for your case, a short-term solution is to use some sort of reverse proxy server like Nginx |
Gotcha, thanks @ndcunningham ! I thought Do you think there would be something in the future that Nx could implement to gap nuances like this? 🙂 |
I can see the use case for this feature. |
I don't think anything is happening on the http-server side. The issue @ndcunningham linked above was closed in favor of a more generic issue that has been open since 2015, http-party/http-server#139. Is there anything that we can do on our side? Maybe move the static files to a new directory before serving them? |
Any update on this would be awesome! I've seen @MaximSagan has added http-party/http-server#837 , but it was not merged for about half a year now D; |
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
Current Behavior
Hello, I’m using [email protected] and React MFE.
I have a problem where
baseHref
works when runningserve
( using@nrwl/react:module-federation-dev-server
) but notserve-static
( using@nrwl/web:file-server
). Here’s an excerpt of my remote config:When I run
nx serve mfeapp1
, the assets get served atbaseHref
e.glocalhost:4401/experiment-mfe/mfeapp1/__dev/remoteEntry.js
However, when I run
nx serve-static mfeapp1
, the assets get served at root e.g.localhost:4401/remoteEntry.js
The problem is that
serve-static
only serves files statically at the output folder, but ignoresbaseHref
.This is a problem that extends to running MFE host apps as well. With the same config above, and the following Webpack config:
Here are the results:
Expected Behavior
The bundled files are served at the same URL consistently, driven by
baseHref
, regardless of the underlying executor.Why is this a problem?
In my case, I have a reverse-proxy that puts both MFE host and app on a custom domain. So instead of using port number to send traffic to the right place, I have to use URL path.
Steps to Reproduce
npx nx generate @nrwl/react:host mfehost --standaloneConfig --remotes="mfeapp1" --no-interactive
baseHref
path e.g./experiment-mfe/mfeapp1/__dev/
nx serve mfeapp1
, remoteEntry is served atlocalhost:4201/experiment-mfe/mfeapp1/__dev/remoteEntry.js
nx serve-static mfeapp1
, remoteEntry is served atlocalhost:4201/remoteEntry.js
Environment
The text was updated successfully, but these errors were encountered: