-
-
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
Server middleware is not included in .nuxt production folder #9158
Comments
@jozef-rzadkosz This is correct - server middleware aren't compiled or part of your webpack build and so you should make sure to copy them separately into production. (As well as making sure that any dependencies they have are installed in production.) (Note that this will change with Nuxt 3 - you'll be able to have a single built server that includes your server middleware.) |
but when i run npm run build ; npm run start it shows in console that db connected , which I have console logged from server's js file so why is that │ Nuxt @ v2.14.12 │ and i can hit apis too but when i run same commands on server it does not work why ? |
@bhumit070 I'm not sure what you're asking. |
I am asking the server middleware works on production build but at deploy time if i run the same command npm run build and npm run start i run command npm run build and npm run start to start the production build why my server middleware is not working |
@bhumit070 My best guess is that it is because your serverMiddleware are in your project on your local machine but when you deploy you are only copying across Make sure to follow my suggestion in #9158 (comment) and you should be fine 👍 . |
how could that be possible what i do is I push to github and then it is connected to azure account which deploys automatically |
@bhumit070 It sounds like there is an issue with the deploy setup, but without more details I couldn't say what the issue is. I would suggest you join https://discord.nuxtjs.org and ask for support there, where it's easier to provide back-and-forth questions and answers. |
Hi, I am new to nuxt. Thanks |
@SergiuPlesco That is only true for Nuxt 2. You can ignore this issue. |
Thanks for your reply. The project i am working on is Next 2. Thanks |
I would advise upgrading to Nuxt 3. |
Versions
Reproduction
Nuxt build server-middleware is not included in .nuxt build folder. I have one server-middleware with one express endpoint like: /contact/send and inside of it I am just sending simply post request and send an email from it by external email provider (SendGrid). Everything is working good but on dev mode, on production I am getting 404 and I cannot target my /contact/send endpoint anymore.
Here's a question in stackoverflow
https://stackoverflow.com/questions/67111986/nuxt-server-middleware-not-working-on-production/67113206?noredirect=1#comment118629365_67113206
Steps to reproduce
If you cannot host this write this:
app.get('/test', (req,res) => {
res.send('test');
})
After that try to find this in your production folder "test" and you will get no matching
What is Expected?
When I write some endpoint to target I need to have it also in production mode after build.
What is actually happening?
Server middleware function are not included in .nuxt folder and we cannot target them in production mode
The text was updated successfully, but these errors were encountered: