Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid caching for specific Nextjs API route?

I have nextjs api route /api/auth/signout, it basically just clears the specific cookie and send JSON back.

The problem is, when I deploy project in Vercel, this particular API working first time properly (cookie cleared and giving 200 response) but later it's not working (cookie not cleared and giving 304 response).

I want to know, is there any way to avoid cache only for this route?

What's the best possible way to fix this problem?

like image 804
Shiva Avatar asked Jun 08 '26 06:06

Shiva


1 Answers

Had a very similar problem with a corn API route and fixed it with

export const revalidate = 0;

in the route.js file

like image 123
Erich García Avatar answered Jun 10 '26 22:06

Erich García



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!