-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vite uses and passes a different server instance to plugins after server restart #15589
Comments
Ok, this is probably a bug in our configuration as it only reproduces with that. Seems like it tries to remove |
The potential Vite issue here would be that
after a restart is not the same instance as the |
The behavior has changed in 5.0.4 |
So probably in #15166. Intentional @patak-dev? Should we fix our conf? |
The existing hacky way of removing the middleware has two issues: 1. It removes it AFTER the first request to a non-existing file so the first request for a non-existing resources index.html and subsequent requests return 404 2. It does not work with Vite 4.0.5+ after restart, see vitejs/vite#15589
Yes, I think the fix you linked is correct here. 5.0.4 started to properly respect app.use(vite.middlewares) you will always be using the middlewares created at server startup, and any changes after a restart were ignored. |
The existing hacky way of removing the middleware has two issues: 1. It removes it AFTER the first request to a non-existing file so the first request for a non-existing resources index.html and subsequent requests return 404 2. It does not work with Vite 4.0.5+ after restart, see vitejs/vite#15589 Co-authored-by: Peter Czuczor <[email protected]>
The existing hacky way of removing the middleware has two issues: 1. It removes it AFTER the first request to a non-existing file so the first request for a non-existing resources index.html and subsequent requests return 404 2. It does not work with Vite 4.0.5+ after restart, see vitejs/vite#15589 Co-authored-by: Peter Czuczor <[email protected]>
) The existing hacky way of removing the middleware has two issues: 1. It removes it AFTER the first request to a non-existing file so the first request for a non-existing resources index.html and subsequent requests return 404 2. It does not work with Vite 4.0.5+ after restart, see vitejs/vite#15589 Co-authored-by: Artur <[email protected]> Co-authored-by: Peter Czuczor <[email protected]>
Describe the bug
curl http://127.0.0.1:5173/VAADIN/foo.js -v
Problem 1, index.html is returned:
curl http://127.0.0.1:5173/VAADIN/foo.js -v
Now it works correctly:
Restart Vite by pressing r+enter in the Vite console
Request the file again, e.g.
curl http://127.0.0.1:5173/VAADIN/foo.js -v
Problem 1, index.html is returned again. And no matter how many times you request the file, index.html is returned.
The reason this is a problem is that we proxy requests to Vite and when Vite does not return a file, we check in other locations. Now when Vite returns the file that does not exist, we do not check for the real
foo.js
and instead serve the wrong file (index.html
)Reproduction
Presumably related to something in the project as it does not reproduce in a simple project
Steps to reproduce
No response
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: