-
-
Notifications
You must be signed in to change notification settings - Fork 5k
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
feat: HMR support for serverMiddleware #6881
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small typo
Can we add maybe a warn for path usage? Or update the docs for serverMiddleware? |
@atinux Internally we normalize path/handler without any warning by this PR to use connect/express convention. We can deprecate it for Nuxt3. |
Please update the docs with examples, because it not working for me. |
I have the same issue as @GaborTorma, only the first change on the server middlewares is detected |
|
@pi0 in our case we're using OSX/Ubuntu, I will try to create an issue with a jsbin later today, thank you! =) |
Does anybody have an example of this working? I am getting this error:
|
@HuddleHouse Would you please ensure having 2.12+ version of |
@pi0 Thanks for responding! That helped me figure out what was wrong. It turns out 2.11+ versions of |
I'm getting the below error after this change, using an Express api backend exported as below: nuxt.config.js: Error: at Server.resolveMiddleware (node_modules/@nuxt/server/dist/server.js:816:35) |
@humanistical I am encountering the same problem. Any fix? |
You need to exports only the app in ~/api/index.js file:
|
@TeleMediaCC Thank you. This solved my problem. For others who may encounter this problem, you don't need to sub route to '/api' inside your express setup. Just export without prepending api to your express routes. Sample setup: express /api/index.js
In nuxt.config.js
This will generate automatically.
|
Types of changes
Description
Fixes #6877 #1509.
This PR brings huge DX improvements to Nuxt serverMiddleware by watching all serverMiddleware (and their require dependency tree). HMR supported for both path and handler.
Changes summary:
Error handling: Normal runtime errors already being handled by error middleware. In case an error happens due to syntax/reference error, a placeholder will be automatically replaced. If path is defined inside same file, we try to preserve last state otherwise show error on all routes until problem is fixes.
Checklist: