[Bug]: When defining dev.assetPrefix to a full URL (http://localhost:3010/subpath/) static files can't be found under said subpath
nate-summercook opened this issue · 2 comments
Version
System:
OS: macOS 14.5
CPU: (10) arm64 Apple M1 Pro
Memory: 7.46 GB / 32.00 GB
Shell: 6.21.00 - /bin/tcsh
Browsers:
Brave Browser: 125.1.66.115
Chrome: 126.0.6478.127
Edge: 126.0.2592.81
Safari: 17.5
Details
I have a rather complicated setup with multiple module federation apps running in parallel. We have start script where you select which apps to start locally and which to proxy in from a deployment (very handy when working with MF). So much for the introduction.
Now because of said setup, we need to define the dev.assetPrefix
path to a full URL (like i.e. http://localhost:3010/subpath/). Because if we only set an absolute URL, when trying to fetch async packages from one of the MF modules, it wouldn't know in which app to search (it would search it in the host app, where it's most probably not).
I noticed that when I set an absolute URL, it will make sure that the static files can be accessed through this absolute URL. Not so much if the assetPrefix is a full URL. The script tag points to the right place, but the JS files will still be located outside the subpath.
If there's another way to achieve this, then I'm happy, but currently, I'm really struggling to get this usecase (different subpath isntead of every app on root) to work.
Reproduce link
https://github.com/nate-summercook/rsbuild-asset-prefix
Reproduce Steps
I guess this could be reproduced without a module federation setup, it's probably a general limitation of rsbuild, that static files won't be accessible on a subpath if the dev.assetPath
is a full URL. It's probably also a desired behavior, but it would be nice to have a way to deal with this. Searched the documentation up and down but didn't find anything.
- Checkout my repro repository
- run
npm i
- run
npm start
- If you change assetPrefix to /subpath/, it will work, but that doesn't help me in my module federation situation.
@9aoy can you help to check this?
I think this is a scenario that rsbuild misses, let me figure out how to support this.