https://glitch.com/edit/#!/heady-cheque
$ touch ./src/api/index.js{
...
srcDir: 'src/',
buildDir: 'dist',
serverMiddleware: ['~/api/index'],
}
$ nuxt builddist andnode_modules` directories to server$ nuxt start on the server (meaning without src/ directory)When Nuxt is started, it shouldn't check for a file existence in the sources, but check for a built one. We shouldn't need to deploy the sources into the server, but only the dependencies and the build directory (.nuxt or dist).
Nuxt will fail because it won't be able to resolve the middleware file since there isn't any src/ folder in the server.
So, you are suggesting copying the middleware files to the dist as well?
and any loader registered in the nuxt.config.js build will not run for files in serverMiddleware
related to #3890 too
@manniL yes, if that's not already the case. All files necessary for runtime should ideally be present in the buildDir.
Thanks guys, I'm looking into this.
@IGassmann can you provide that glitch as a git repo or downloadable file? Or grant me access to download over at Glitch itself, of course.
Here it is: https://github.com/IGassmann/nuxt-servermiddleware-issue
Check out the commit history. The files that are currently in the repo mirror a server deployment. After cloning the repo, just run $ yarn start and you'll see the error I'm referencing.
@IGassmann thanks, saw it -- I'm pushing a fix soon cc @Atinux
Please check the Bug #3955 (Nuxt servermiddleware route /api is ignored when deployed or served on Firebase). It seems a related problem.....
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
@galvez have you been able to fix this?
Is there any workaround?
Moving the serverMiddleware in the dist folder would lead to broken relative imports, which is somewhat hard to "prevent"/"avoid".
Instead, the documentation will include which files have to be present on the server soon:tm:.
Thanks for your contribution to Nuxt.js!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you would like this issue to remain open:
Issues that are labeled as 馃晲Pending will not be automatically marked as stale.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.