Nodemailer sends emails on development but not in production
Answered
Ashy Storm-Petrel posted this in #help-forum

Ashy Storm-PetrelOP
i've upload to vercel and this is insane why such a thing happens only in production
20 Replies

Ashy Storm-PetrelOP
turn out nextjs is just caching first request and not sending new one

the new cache system is frustating

@dumbboy the new cache system is frustating

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

Honestly I don't know too

Try:
In the route handler
export const dynamic = 'force-dynamic'
In the route handler
Answer

@Clown Try:
`export const dynamic = 'force-dynamic'`
In the route handler

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

@Ashy Storm-Petrel The answer was that
first add
js
export const dynamic = 'force-dynamic'
then the response had to be dynamic because my response was
json
{Success: true}
so i had to put something changing so it ended up doing
js
{Success: `true ${Math.random()}`
not the best approach but worked

so, it worked, can you mark this post as solved?

@dumbboy so, it worked, can you mark this post as solved?

Ashy Storm-PetrelOP
how can i do that?


@Ashy Storm-Petrel how can i do that?

Select the message that helped you solve this, apps -> mark as solution
Original message was deleted

@Ashy Storm-Petrel The answer was that
first add
js
export const dynamic = 'force-dynamic'
then the response had to be dynamic because my response was
json
{Success: true}
so i had to put something changing so it ended up doing
js
{Success: `true ${Math.random()}`
not the best approach but worked

Transvaal lion
Can you please explain you solution a bit more like, where did you do
{Success: `true ${Math.random()}

@Transvaal lion Can you please explain you solution a bit more like, where did you do
{Success: `true ${Math.random()}

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

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?

@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?

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)