-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Description
Clear and concise description of the problem
We're setting up a project simulating micro-frontend like qiankun in development, for this to work we need to respond index as a special "wrapper" html with qiankun runtime and a startup script pulling actual project, just like:
<script src="/__local_qiankun_bundle__.js"></script>
<script>
qiankun.registerMicroApps([
{
name: 'xxx',
entry: '/index.html', // The actual index html
container: '#root',
activeRule: '/',
}
]);
qiankun.start();
</script>(This is only an example, actually we bundle qiankun runtime and entry script with esbuild.)
We then need to modify dev server's route into:
- history api fallback to
/__qiankun_wrapper__.htmlwhich responds content described above - on
/__local_qiankun_bundle__.jsresponds a bundled version of qiankun /index.htmlto serve as what vite did not
Without the ability to customize historyApiFallback middleware, it is not possible to setup a server exactly do these staffs, and historyApiFallback is a special middleware that we cannot add another one before or after vite's middleware array.
Suggested solution
Expose server.apiHistoryFallbackOptions to allow user customize this behavior.
Alternative
Another solution is to allow a server.historyApiFallback: false option to intentionally disable history api fallback behavior, users can then add this middleware on demand.
Additional context
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.