gioboa / svelte-microfrontend-demo

Svelte+Vite with Module Federation is now possible
35 stars 9 forks source link

Host app remoteEntry.json is not being loaded when app url contains client side routing segments #4

Closed xoneill closed 1 year ago

xoneill commented 1 year ago

In my Svelte Native Federation solution I am using svelte-pathfinder router which is configured to work in non-hashbang mode: http://localhost:3000/pageA/featureA/ where /pageA/featureA/ - client side routing segments

Everything is working fine if to open the app at http://localhost:3000. But if you try to refresh the browser while being on the feature screen, you will get an error:

GET http://localhost:3000/pageA/featureA/remoteEntry.json 404

I looked at the code of the @softarc/native-federation-runtime package. In init-federation function processHostInfo contains relative paths './' which cause this problem. Is it possible to replace it with root-relative paths / or maybe make it configurable, so I can set it that way? It would solve my problem

Thanks

gioboa commented 1 year ago

Hi, thanks for your feedback, I will look at it

gioboa commented 1 year ago

Yes, nice research @xoneill

Screenshot 2023-02-17 at 09 01 58

Here the library is looking for the host remote entry from the current path and not from the host origin I can't modify the code of this external library but I can tag the creator 😄 @manfredsteyer can you please look at this issue? thanks 🙏

xoneill commented 1 year ago

Here the library is looking for the host remote entry from the current path and not from the host origin

Yeah, there are several places in that function that use './' :

image

I can't modify the code of this external library but I can tag the creator 😄

Sorry about that. I just couldn't find @softarc/native-federation on github

Thank you guys for your assistance

gioboa commented 1 year ago

here you can find the code https://github.com/angular-architects/module-federation-plugin/tree/main/libs/native-federation