module-federation / module-federation-examples

Implementation examples of module federation , by the creators of module federation
https://module-federation.io/
MIT License
5.65k stars 1.75k forks source link

Problem to run example Modern.js ssr #4259

Closed alexandesigner closed 3 weeks ago

alexandesigner commented 2 months ago

I'm running the example without changing anything and when accessing localhost:3006 the remote applications don't run, the IP is being changed from localhost to 192.168.0.192.

Example link: https://github.com/module-federation/module-federation-examples/tree/master/modernjs-ssr

Access files directly with localhost is working correctly.

Reproduce:

Screenshot 2024-08-28 at 12 52 34 Screenshot 2024-08-28 at 12 52 23

Is there any way around this change?

2heal1 commented 2 months ago

Becasue node will auto resolve the localhost to ipv6/ipv4 via your /etc/hosts configuration . And it not support ipv6 now , so i will auto change the localhost to ipv4.

But it's very strange that you can not access the resource via ipv4, you can try add the config in moduleFederationPlugin : {remoteIpStrategy:'inherit'}

2heal1 commented 2 months ago

And what's the app of localhost:3009 ? Do you change the host 's port ?

If still not resolve the issue , please provide the env by the cmd npx envinfo --system --binaries --browsers

alexandesigner commented 2 months ago

@2heal1 heeey..

thank you very much for your response!

the solution worked using the { remoteIpStrategy: 'inherit' } property.

However, based on what I see in the current typings, I believe we could enhance the documentation to explicitly include these configuration options within the plugin. What do you think?

And what's the app of localhost:3009 ? Do you change the host 's port ?

Just me changing the settings to see if it reflected haha

alexandesigner commented 2 months ago

Another problem I'm having is after the build... when I'm running the project, getting a CORS error, i don't know exactly if it's with module federation or in the modernjs project. Why with Garfish (modernjs mfe solution) I also get this error.