Nodemailer sends emails on development but not in production
Answered
Ashy Storm-Petrel posted this in #help-forum
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Ashy Storm-PetrelOP
i've upload to vercel and this is insane why such a thing happens only in production
20 Replies
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Ashy Storm-PetrelOP
turn out nextjs is just caching first request and not sending new one
![Avatar](https://cdn.discordapp.com/avatars/839454110302732309/d3f0b9db767484084f52339f0b4f2385.webp?size=256)
dumbboy
the new cache system is frustating
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Ashy Storm-PetrelOP
can i disable it on my api routes?
i tried to do fetch no store in the frontend but that didn't fix it
![Avatar](https://cdn.discordapp.com/avatars/839454110302732309/d3f0b9db767484084f52339f0b4f2385.webp?size=256)
dumbboy
Honestly I don't know too
![Avatar](https://cdn.discordapp.com/avatars/678259999201427466/54265510de155a7d7909e4d21d587a76.webp?size=256)
Clown
Try:
In the route handler
export const dynamic = 'force-dynamic'
In the route handler
Answer
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Ashy Storm-PetrelOP
Thank you that's half the answer
The answer was that
first add
then the response had to be dynamic because my response was
so i had to put something changing so it ended up doing
not the best approach but worked
first add
export const dynamic = 'force-dynamic'
then the response had to be dynamic because my response was
{Success: true}
so i had to put something changing so it ended up doing
{Success: `true ${Math.random()}`
not the best approach but worked
![Avatar](https://cdn.discordapp.com/avatars/839454110302732309/d3f0b9db767484084f52339f0b4f2385.webp?size=256)
dumbboy
so, it worked, can you mark this post as solved?
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Ashy Storm-PetrelOP
how can i do that?
![Image](https://cdn.discordapp.com/attachments/1160930671942959104/1160979320899129384/image.png?ex=6536a140&is=65242c40&hm=f8efd6657889306c0ab9359558f8c531121542acc14b46e390abd475a2ab6a19&)
![Avatar](https://cdn.discordapp.com/avatars/839454110302732309/d3f0b9db767484084f52339f0b4f2385.webp?size=256)
dumbboy
Select the message that helped you solve this, apps -> mark as solution
^
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
Transvaal lion
Can you please explain you solution a bit more like, where did you do
{Success: `true ${Math.random()}
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Ashy Storm-PetrelOP
On every response that nextjs sends so every request made will always make new response and not cache the data
Success true is just my message to tell the frontend that the mail is sent
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
Transvaal lion
I have tried this but not working for me. I am using brevo SMTP for sending mail to users which do not have their password set yet... It is working fine on local but on production it is not working... Also please do let me know if there is any way you know for debugging production code?
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Ashy Storm-PetrelOP
tbh for me i just kept pushing my changes wait for building and test
what i did is i made a test endpoint which will send email as soon as i get to it and the response would be the results of the endpoints to see the message ID (will be new each time you sent email)
what i did is i made a test endpoint which will send email as soon as i get to it and the response would be the results of the endpoints to see the message ID (will be new each time you sent email)