-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Allow disabling spa middleware #5720
Description
Clear and concise description of the problem
We are running Vite from Java and to talk to the dev server, we use its http server. We are kind of wanting to run it in middleware mode but cannot use middleware mode directly. In this case, the viteSpaFallbackMiddleware is undesireable as the actual SPA part of the application is handled through a Java server and we want to load frontend resources from Vite. Having the spa middleware enable makes it impossible to know if a certain URL refers to a frontend resource or not, as all URLs that do not refer to resources will still return 200 and the index.html contents.
Suggested solution
Add an option to disable viteSpaFallbackMiddleware even when the middleware option is off.
Alternative
We are currently removing the middleware by force using something like
context.server.middlewares.stack = context.server.middlewares.stack.filter((mw) => {
const handleName = '' + mw.handle;
return !handleName.includes('viteSpaFallbackMiddleware');
});
It is not pretty
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.